home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 4 / Macwelt DVD 4.cdr / Entwickler / Mac-OS X / Pantomime / Source / LocalFolder.m < prev    next >
MacBinary  |  2002-08-20  |  23.8 KB  |  [□□□□/□□□□]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
66% dexvert Ultima 6 (music/ultima6) ext Supported
1% dexvert PC-98 Music (music/pc98Music) ext Unsupported
1% dexvert Amiga E Module (other/amigaEModule) ext Unsupported
1% dexvert ECX module (other/ecxModule) ext Unsupported
1% dexvert Maple Common Binary (other/mapleCommonBinary) ext Unsupported
1% dexvert MacBinary (archive/macBinary) fallback Supported
100% file MacBinary II, inited, Tue Aug 20 07:43:10 2002, modified Tue Aug 20 07:43:10 2002, 23774 bytes "LocalFolder.m" , at 0x5d5e 286 bytes resource default (weak)
99% file data default
100% TrID MacBinary 2 default (weak)
100% dearkID deark: macbinary default
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[□□□□]
macFileCreator[□□□□]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0d 4c 6f 63 61 6c 46 | 6f 6c 64 65 72 2e 6d 00 |..LocalF|older.m.|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 00 00 00 00 00 00 00 | 00 01 00 00 00 00 00 00 |........|........|
|00000050| 00 00 00 00 00 5c de 00 | 00 01 1e b9 87 db ce b9 |.....\..|........|
|00000060| 87 db ce 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 08 4f 00 00 |........|.....O..|
|00000080| 2f 2a 0a 2a 2a 20 20 4c | 6f 63 61 6c 46 6f 6c 64 |/*.** L|ocalFold|
|00000090| 65 72 2e 6d 0a 2a 2a 0a | 2a 2a 20 20 43 6f 70 79 |er.m.**.|** Copy|
|000000a0| 72 69 67 68 74 20 28 63 | 29 20 32 30 30 31 2c 20 |right (c|) 2001, |
|000000b0| 32 30 30 32 0a 2a 2a 0a | 2a 2a 20 20 41 75 74 68 |2002.**.|** Auth|
|000000c0| 6f 72 3a 20 4c 75 64 6f | 76 69 63 20 4d 61 72 63 |or: Ludo|vic Marc|
|000000d0| 6f 74 74 65 20 3c 6c 75 | 64 6f 76 69 63 40 53 6f |otte <lu|dovic@So|
|000000e0| 70 68 6f 73 2e 63 61 3e | 0a 2a 2a 0a 2a 2a 20 20 |phos.ca>|.**.** |
|000000f0| 54 68 69 73 20 6c 69 62 | 72 61 72 79 20 69 73 20 |This lib|rary is |
|00000100| 66 72 65 65 20 73 6f 66 | 74 77 61 72 65 3b 20 79 |free sof|tware; y|
|00000110| 6f 75 20 63 61 6e 20 72 | 65 64 69 73 74 72 69 62 |ou can r|edistrib|
|00000120| 75 74 65 20 69 74 20 61 | 6e 64 2f 6f 72 0a 2a 2a |ute it a|nd/or.**|
|00000130| 20 20 6d 6f 64 69 66 79 | 20 69 74 20 75 6e 64 65 | modify| it unde|
|00000140| 72 20 74 68 65 20 74 65 | 72 6d 73 20 6f 66 20 74 |r the te|rms of t|
|00000150| 68 65 20 47 4e 55 20 4c | 65 73 73 65 72 20 47 65 |he GNU L|esser Ge|
|00000160| 6e 65 72 61 6c 20 50 75 | 62 6c 69 63 0a 2a 2a 20 |neral Pu|blic.** |
|00000170| 20 4c 69 63 65 6e 73 65 | 20 61 73 20 70 75 62 6c | License| as publ|
|00000180| 69 73 68 65 64 20 62 79 | 20 74 68 65 20 46 72 65 |ished by| the Fre|
|00000190| 65 20 53 6f 66 74 77 61 | 72 65 20 46 6f 75 6e 64 |e Softwa|re Found|
|000001a0| 61 74 69 6f 6e 3b 20 65 | 69 74 68 65 72 0a 2a 2a |ation; e|ither.**|
|000001b0| 20 20 76 65 72 73 69 6f | 6e 20 32 2e 31 20 6f 66 | versio|n 2.1 of|
|000001c0| 20 74 68 65 20 4c 69 63 | 65 6e 73 65 2c 20 6f 72 | the Lic|ense, or|
|000001d0| 20 28 61 74 20 79 6f 75 | 72 20 6f 70 74 69 6f 6e | (at you|r option|
|000001e0| 29 20 61 6e 79 20 6c 61 | 74 65 72 20 76 65 72 73 |) any la|ter vers|
|000001f0| 69 6f 6e 2e 0a 2a 2a 20 | 20 0a 2a 2a 20 20 54 68 |ion..** | .** Th|
|00000200| 69 73 20 6c 69 62 72 61 | 72 79 20 69 73 20 64 69 |is libra|ry is di|
|00000210| 73 74 72 69 62 75 74 65 | 64 20 69 6e 20 74 68 65 |stribute|d in the|
|00000220| 20 68 6f 70 65 20 74 68 | 61 74 20 69 74 20 77 69 | hope th|at it wi|
|00000230| 6c 6c 20 62 65 20 75 73 | 65 66 75 6c 2c 0a 2a 2a |ll be us|eful,.**|
|00000240| 20 20 62 75 74 20 57 49 | 54 48 4f 55 54 20 41 4e | but WI|THOUT AN|
|00000250| 59 20 57 41 52 52 41 4e | 54 59 3b 20 77 69 74 68 |Y WARRAN|TY; with|
|00000260| 6f 75 74 20 65 76 65 6e | 20 74 68 65 20 69 6d 70 |out even| the imp|
|00000270| 6c 69 65 64 20 77 61 72 | 72 61 6e 74 79 20 6f 66 |lied war|ranty of|
|00000280| 0a 2a 2a 20 20 4d 45 52 | 43 48 41 4e 54 41 42 49 |.** MER|CHANTABI|
|00000290| 4c 49 54 59 20 6f 72 20 | 46 49 54 4e 45 53 53 20 |LITY or |FITNESS |
|000002a0| 46 4f 52 20 41 20 50 41 | 52 54 49 43 55 4c 41 52 |FOR A PA|RTICULAR|
|000002b0| 20 50 55 52 50 4f 53 45 | 2e 20 53 65 65 20 74 68 | PURPOSE|. See th|
|000002c0| 65 20 47 4e 55 0a 2a 2a | 20 20 4c 65 73 73 65 72 |e GNU.**| Lesser|
|000002d0| 20 47 65 6e 65 72 61 6c | 20 50 75 62 6c 69 63 20 | General| Public |
|000002e0| 4c 69 63 65 6e 73 65 20 | 66 6f 72 20 6d 6f 72 65 |License |for more|
|000002f0| 20 64 65 74 61 69 6c 73 | 2e 0a 2a 2a 20 20 0a 2a | details|..** .*|
|00000300| 2a 20 20 59 6f 75 20 73 | 68 6f 75 6c 64 20 68 61 |* You s|hould ha|
|00000310| 76 65 20 72 65 63 65 69 | 76 65 64 20 61 20 63 6f |ve recei|ved a co|
|00000320| 70 79 20 6f 66 20 74 68 | 65 20 47 4e 55 20 4c 65 |py of th|e GNU Le|
|00000330| 73 73 65 72 20 47 65 6e | 65 72 61 6c 20 50 75 62 |sser Gen|eral Pub|
|00000340| 6c 69 63 0a 2a 2a 20 20 | 4c 69 63 65 6e 73 65 20 |lic.** |License |
|00000350| 61 6c 6f 6e 67 20 77 69 | 74 68 20 74 68 69 73 20 |along wi|th this |
|00000360| 6c 69 62 72 61 72 79 3b | 20 69 66 20 6e 6f 74 2c |library;| if not,|
|00000370| 20 77 72 69 74 65 20 74 | 6f 20 74 68 65 20 46 72 | write t|o the Fr|
|00000380| 65 65 20 53 6f 66 74 77 | 61 72 65 0a 2a 2a 20 20 |ee Softw|are.** |
|00000390| 46 6f 75 6e 64 61 74 69 | 6f 6e 2c 20 49 6e 63 2e |Foundati|on, Inc.|
|000003a0| 2c 20 35 39 20 54 65 6d | 70 6c 65 20 50 6c 61 63 |, 59 Tem|ple Plac|
|000003b0| 65 2c 20 53 75 69 74 65 | 20 33 33 30 2c 20 42 6f |e, Suite| 330, Bo|
|000003c0| 73 74 6f 6e 2c 20 4d 41 | 20 30 32 31 31 31 2d 31 |ston, MA| 02111-1|
|000003d0| 33 30 37 20 55 53 41 0a | 2a 2f 0a 23 69 6d 70 6f |307 USA.|*/.#impo|
|000003e0| 72 74 20 3c 50 61 6e 74 | 6f 6d 69 6d 65 2f 4c 6f |rt <Pant|omime/Lo|
|000003f0| 63 61 6c 46 6f 6c 64 65 | 72 2e 68 3e 0a 0a 23 69 |calFolde|r.h>..#i|
|00000400| 6d 70 6f 72 74 20 3c 50 | 61 6e 74 6f 6d 69 6d 65 |mport <P|antomime|
|00000410| 2f 43 6f 6e 73 74 61 6e | 74 73 2e 68 3e 0a 23 69 |/Constan|ts.h>.#i|
|00000420| 6d 70 6f 72 74 20 3c 50 | 61 6e 74 6f 6d 69 6d 65 |mport <P|antomime|
|00000430| 2f 46 6c 61 67 73 2e 68 | 3e 0a 23 69 6d 70 6f 72 |/Flags.h|>.#impor|
|00000440| 74 20 3c 50 61 6e 74 6f | 6d 69 6d 65 2f 4c 6f 63 |t <Panto|mime/Loc|
|00000450| 61 6c 46 6f 6c 64 65 72 | 43 61 63 68 65 4d 61 6e |alFolder|CacheMan|
|00000460| 61 67 65 72 2e 68 3e 0a | 23 69 6d 70 6f 72 74 20 |ager.h>.|#import |
|00000470| 3c 50 61 6e 74 6f 6d 69 | 6d 65 2f 4c 6f 63 61 6c |<Pantomi|me/Local|
|00000480| 4d 65 73 73 61 67 65 2e | 68 3e 0a 23 69 6d 70 6f |Message.|h>.#impo|
|00000490| 72 74 20 3c 50 61 6e 74 | 6f 6d 69 6d 65 2f 4c 6f |rt <Pant|omime/Lo|
|000004a0| 63 61 6c 53 74 6f 72 65 | 2e 68 3e 0a 23 69 6d 70 |calStore|.h>.#imp|
|000004b0| 6f 72 74 20 3c 50 61 6e | 74 6f 6d 69 6d 65 2f 50 |ort <Pan|tomime/P|
|000004c0| 61 72 73 65 72 2e 68 3e | 0a 23 69 6d 70 6f 72 74 |arser.h>|.#import|
|000004d0| 20 3c 50 61 6e 74 6f 6d | 69 6d 65 2f 4e 53 44 61 | <Pantom|ime/NSDa|
|000004e0| 74 61 45 78 74 65 6e 73 | 69 6f 6e 73 2e 68 3e 0a |taExtens|ions.h>.|
|000004f0| 0a 23 69 6d 70 6f 72 74 | 20 3c 66 63 6e 74 6c 2e |.#import| <fcntl.|
|00000500| 68 3e 0a 23 69 6d 70 6f | 72 74 20 3c 75 6e 69 73 |h>.#impo|rt <unis|
|00000510| 74 64 2e 68 3e 0a 23 69 | 6d 70 6f 72 74 20 3c 73 |td.h>.#i|mport <s|
|00000520| 74 72 69 6e 67 2e 68 3e | 0a 23 69 6d 70 6f 72 74 |tring.h>|.#import|
|00000530| 20 3c 73 79 73 2f 66 69 | 6c 65 2e 68 3e 0a 0a 23 | <sys/fi|le.h>..#|
|00000540| 69 66 6e 64 65 66 20 4c | 4f 43 4b 5f 53 48 0a 23 |ifndef L|OCK_SH.#|
|00000550| 64 65 66 69 6e 65 20 4c | 4f 43 4b 5f 53 48 20 31 |define L|OCK_SH 1|
|00000560| 0a 23 65 6e 64 69 66 0a | 23 69 66 6e 64 65 66 20 |.#endif.|#ifndef |
|00000570| 4c 4f 43 4b 5f 45 58 0a | 23 64 65 66 69 6e 65 20 |LOCK_EX.|#define |
|00000580| 4c 4f 43 4b 5f 45 58 20 | 32 0a 23 65 6e 64 69 66 |LOCK_EX |2.#endif|
|00000590| 20 0a 23 69 66 6e 64 65 | 66 20 4c 4f 43 4b 5f 4e | .#ifnde|f LOCK_N|
|000005a0| 42 0a 23 64 65 66 69 6e | 65 20 4c 4f 43 4b 5f 4e |B.#defin|e LOCK_N|
|000005b0| 42 20 34 0a 23 65 6e 64 | 69 66 0a 23 69 66 6e 64 |B 4.#end|if.#ifnd|
|000005c0| 65 66 20 4c 4f 43 4b 5f | 55 4e 0a 23 64 65 66 69 |ef LOCK_|UN.#defi|
|000005d0| 6e 65 20 4c 4f 43 4b 5f | 55 4e 20 38 0a 23 65 6e |ne LOCK_|UN 8.#en|
|000005e0| 64 69 66 0a 0a 40 69 6d | 70 6c 65 6d 65 6e 74 61 |dif..@im|plementa|
|000005f0| 74 69 6f 6e 20 4c 6f 63 | 61 6c 46 6f 6c 64 65 72 |tion Loc|alFolder|
|00000600| 0a 0a 2d 20 28 69 64 29 | 20 69 6e 69 74 57 69 74 |..- (id)| initWit|
|00000610| 68 50 61 74 68 54 6f 46 | 69 6c 65 3a 20 28 4e 53 |hPathToF|ile: (NS|
|00000620| 53 74 72 69 6e 67 20 2a | 29 20 74 68 65 50 61 74 |String *|) thePat|
|00000630| 68 0a 7b 0a 20 20 4c 6f | 63 61 6c 46 6f 6c 64 65 |h.{. Lo|calFolde|
|00000640| 72 43 61 63 68 65 4d 61 | 6e 61 67 65 72 20 2a 61 |rCacheMa|nager *a|
|00000650| 4c 6f 63 61 6c 46 6f 6c | 64 65 72 43 61 63 68 65 |LocalFol|derCache|
|00000660| 4d 61 6e 61 67 65 72 3b | 0a 20 20 4e 53 44 69 63 |Manager;|. NSDic|
|00000670| 74 69 6f 6e 61 72 79 20 | 2a 61 74 74 72 69 62 75 |tionary |*attribu|
|00000680| 74 65 73 3b 0a 20 20 4e | 53 53 74 72 69 6e 67 20 |tes;. N|SString |
|00000690| 2a 70 61 74 68 54 6f 43 | 61 63 68 65 3b 0a 20 20 |*pathToC|ache;. |
|000006a0| 0a 20 20 73 65 6c 66 20 | 3d 20 5b 73 75 70 65 72 |. self |= [super|
|000006b0| 20 69 6e 69 74 57 69 74 | 68 4e 61 6d 65 3a 20 5b | initWit|hName: [|
|000006c0| 74 68 65 50 61 74 68 20 | 6c 61 73 74 50 61 74 68 |thePath |lastPath|
|000006d0| 43 6f 6d 70 6f 6e 65 6e | 74 5d 5d 3b 0a 0a 20 20 |Componen|t]];.. |
|000006e0| 2f 2f 20 57 65 20 76 65 | 72 69 66 79 20 69 66 20 |// We ve|rify if |
|000006f0| 61 20 3c 6e 61 6d 65 3e | 2e 74 6d 70 20 77 61 73 |a <name>|.tmp was|
|00000700| 20 70 72 65 73 65 6e 74 | 2e 20 49 66 20 79 65 73 | present|. If yes|
|00000710| 2c 20 77 65 20 73 69 6d | 70 6c 79 20 72 65 6d 6f |, we sim|ply remo|
|00000720| 76 65 20 69 74 2e 0a 20 | 20 69 66 20 28 20 5b 5b |ve it.. | if ( [[|
|00000730| 4e 53 46 69 6c 65 4d 61 | 6e 61 67 65 72 20 64 65 |NSFileMa|nager de|
|00000740| 66 61 75 6c 74 4d 61 6e | 61 67 65 72 5d 20 66 69 |faultMan|ager] fi|
|00000750| 6c 65 45 78 69 73 74 73 | 41 74 50 61 74 68 3a 20 |leExists|AtPath: |
|00000760| 5b 74 68 65 50 61 74 68 | 20 73 74 72 69 6e 67 42 |[thePath| stringB|
|00000770| 79 41 70 70 65 6e 64 69 | 6e 67 53 74 72 69 6e 67 |yAppendi|ngString|
|00000780| 3a 20 40 22 2e 74 6d 70 | 22 5d 5d 20 29 0a 20 20 |: @".tmp|"]] ). |
|00000790| 20 20 7b 0a 20 20 20 20 | 20 20 2f 2f 4e 53 44 65 | {. | //NSDe|
|000007a0| 62 75 67 4c 6f 67 28 40 | 22 52 65 6d 6f 76 65 64 |bugLog(@|"Removed|
|000007b0| 20 25 40 22 2c 20 5b 74 | 68 65 50 61 74 68 20 73 | %@", [t|hePath s|
|000007c0| 74 72 69 6e 67 42 79 41 | 70 70 65 6e 64 69 6e 67 |tringByA|ppending|
|000007d0| 53 74 72 69 6e 67 3a 20 | 40 22 2e 74 6d 70 22 5d |String: |@".tmp"]|
|000007e0| 29 3b 0a 20 20 20 20 20 | 20 5b 5b 4e 53 46 69 6c |);. | [[NSFil|
|000007f0| 65 4d 61 6e 61 67 65 72 | 20 64 65 66 61 75 6c 74 |eManager| default|
|00000800| 4d 61 6e 61 67 65 72 5d | 20 72 65 6d 6f 76 65 46 |Manager]| removeF|
|00000810| 69 6c 65 41 74 50 61 74 | 68 3a 20 5b 74 68 65 50 |ileAtPat|h: [theP|
|00000820| 61 74 68 20 73 74 72 69 | 6e 67 42 79 41 70 70 65 |ath stri|ngByAppe|
|00000830| 6e 64 69 6e 67 53 74 72 | 69 6e 67 3a 20 40 22 2e |ndingStr|ing: @".|
|00000840| 74 6d 70 22 5d 0a 09 09 | 09 09 20 20 20 20 20 20 |tmp"]...|.. |
|00000850| 68 61 6e 64 6c 65 72 3a | 20 6e 69 6c 5d 3b 0a 20 |handler:| nil];. |
|00000860| 20 20 20 7d 0a 0a 20 20 | 5b 73 65 6c 66 20 73 65 | }.. |[self se|
|00000870| 74 50 61 74 68 3a 20 74 | 68 65 50 61 74 68 5d 3b |tPath: t|hePath];|
|00000880| 0a 20 20 0a 20 20 2f 2f | 4e 53 44 65 62 75 67 4c |. . //|NSDebugL|
|00000890| 6f 67 28 40 22 4f 70 65 | 6e 69 6e 67 20 25 40 2e |og(@"Ope|ning %@.|
|000008a0| 2e 2e 22 2c 20 5b 73 65 | 6c 66 20 70 61 74 68 5d |..", [se|lf path]|
|000008b0| 29 3b 0a 20 20 0a 20 20 | 69 66 20 28 21 20 5b 73 |);. . |if (! [s|
|000008c0| 65 6c 66 20 5f 6f 70 65 | 6e 41 6e 64 4c 6f 63 6b |elf _ope|nAndLock|
|000008d0| 46 6f 6c 64 65 72 5d 20 | 29 0a 20 20 20 20 7b 0a |Folder] |). {.|
|000008e0| 20 20 20 20 20 20 41 55 | 54 4f 52 45 4c 45 41 53 | AU|TORELEAS|
|000008f0| 45 28 73 65 6c 66 29 3b | 0a 20 20 20 20 20 20 72 |E(self);|. r|
|00000900| 65 74 75 72 6e 20 6e 69 | 6c 3b 0a 20 20 20 20 7d |eturn ni|l;. }|
|00000910| 0a 20 20 0a 20 20 2f 2f | 20 57 65 20 6c 6f 61 64 |. . //| We load|
|00000920| 20 6f 75 72 20 63 61 63 | 68 65 0a 20 20 70 61 74 | our cac|he. pat|
|00000930| 68 54 6f 43 61 63 68 65 | 20 3d 20 5b 4e 53 53 74 |hToCache| = [NSSt|
|00000940| 72 69 6e 67 20 73 74 72 | 69 6e 67 57 69 74 68 46 |ring str|ingWithF|
|00000950| 6f 72 6d 61 74 3a 20 40 | 22 25 40 2f 2e 25 40 2e |ormat: @|"%@/.%@.|
|00000960| 63 61 63 68 65 22 2c 0a | 09 09 09 20 20 5b 5b 73 |cache",.|... [[s|
|00000970| 65 6c 66 20 70 61 74 68 | 5d 20 73 75 62 73 74 72 |elf path|] substr|
|00000980| 69 6e 67 54 6f 49 6e 64 | 65 78 3a 20 0a 09 09 09 |ingToInd|ex: ....|
|00000990| 09 09 20 28 5b 5b 73 65 | 6c 66 20 70 61 74 68 5d |.. ([[se|lf path]|
|000009a0| 20 6c 65 6e 67 74 68 5d | 20 2d 20 5b 5b 5b 73 65 | length]| - [[[se|
|000009b0| 6c 66 20 70 61 74 68 5d | 20 6c 61 73 74 50 61 74 |lf path]| lastPat|
|000009c0| 68 43 6f 6d 70 6f 6e 65 | 6e 74 5d 20 6c 65 6e 67 |hCompone|nt] leng|
|000009d0| 74 68 5d 29 5d 2c 0a 09 | 09 09 20 20 5b 5b 73 65 |th])],..|.. [[se|
|000009e0| 6c 66 20 70 61 74 68 5d | 20 6c 61 73 74 50 61 74 |lf path]| lastPat|
|000009f0| 68 43 6f 6d 70 6f 6e 65 | 6e 74 5d 20 5d 3b 0a 20 |hCompone|nt] ];. |
|00000a00| 20 0a 20 20 61 74 74 72 | 69 62 75 74 65 73 20 3d | . attr|ibutes =|
|00000a10| 20 5b 5b 4e 53 46 69 6c | 65 4d 61 6e 61 67 65 72 | [[NSFil|eManager|
|00000a20| 20 64 65 66 61 75 6c 74 | 4d 61 6e 61 67 65 72 5d | default|Manager]|
|00000a30| 20 66 69 6c 65 41 74 74 | 72 69 62 75 74 65 73 41 | fileAtt|ributesA|
|00000a40| 74 50 61 74 68 3a 20 5b | 73 65 6c 66 20 70 61 74 |tPath: [|self pat|
|00000a50| 68 5d 0a 09 09 09 09 09 | 20 20 20 20 20 20 20 74 |h]......| t|
|00000a60| 72 61 76 65 72 73 65 4c | 69 6e 6b 3a 20 4e 4f 5d |raverseL|ink: NO]|
|00000a70| 3b 0a 0a 20 20 2f 2f 20 | 57 65 20 73 65 74 20 6f |;.. // |We set o|
|00000a80| 75 72 20 69 6e 69 74 69 | 61 6c 20 66 69 6c 65 20 |ur initi|al file |
|00000a90| 61 74 74 72 69 62 75 74 | 65 73 20 66 6f 72 20 74 |attribut|es for t|
|00000aa0| 68 65 20 6d 62 6f 78 0a | 20 20 5b 73 65 6c 66 20 |he mbox.| [self |
|00000ab0| 73 65 74 46 69 6c 65 41 | 74 74 72 69 62 75 74 65 |setFileA|ttribute|
|00000ac0| 73 3a 20 61 74 74 72 69 | 62 75 74 65 73 5d 3b 0a |s: attri|butes];.|
|00000ad0| 20 20 0a 20 20 2f 2f 20 | 57 65 20 6c 6f 61 64 20 | . // |We load |
|00000ae0| 6f 75 72 20 63 61 63 68 | 65 20 66 72 6f 6d 20 74 |our cach|e from t|
|00000af0| 68 65 20 66 69 6c 65 2c | 20 63 72 65 61 74 69 6e |he file,| creatin|
|00000b00| 67 20 69 74 20 69 66 20 | 69 74 20 64 6f 65 73 6e |g it if |it doesn|
|00000b10| 27 74 20 65 78 69 73 74 | 0a 20 20 61 4c 6f 63 61 |'t exist|. aLoca|
|00000b20| 6c 46 6f 6c 64 65 72 43 | 61 63 68 65 4d 61 6e 61 |lFolderC|acheMana|
|00000b30| 67 65 72 20 3d 20 5b 4c | 6f 63 61 6c 46 6f 6c 64 |ger = [L|ocalFold|
|00000b40| 65 72 43 61 63 68 65 4d | 61 6e 61 67 65 72 20 6c |erCacheM|anager l|
|00000b50| 6f 63 61 6c 46 6f 6c 64 | 65 72 43 61 63 68 65 46 |ocalFold|erCacheF|
|00000b60| 72 6f 6d 44 69 73 6b 57 | 69 74 68 50 61 74 68 3a |romDiskW|ithPath:|
|00000b70| 20 70 61 74 68 54 6f 43 | 61 63 68 65 5d 3b 20 20 | pathToC|ache]; |
|00000b80| 0a 20 20 5b 73 65 6c 66 | 20 73 65 74 4c 6f 63 61 |. [self| setLoca|
|00000b90| 6c 46 6f 6c 64 65 72 43 | 61 63 68 65 4d 61 6e 61 |lFolderC|acheMana|
|00000ba0| 67 65 72 3a 20 61 4c 6f | 63 61 6c 46 6f 6c 64 65 |ger: aLo|calFolde|
|00000bb0| 72 43 61 63 68 65 4d 61 | 6e 61 67 65 72 5d 3b 0a |rCacheMa|nager];.|
|00000bc0| 0a 20 20 2f 2f 20 57 65 | 20 75 70 64 61 74 65 20 |. // We| update |
|00000bd0| 74 68 65 20 70 61 74 68 | 20 74 6f 20 74 68 69 73 |the path| to this|
|00000be0| 20 66 6f 6c 64 65 72 20 | 66 6f 72 20 74 68 65 20 | folder |for the |
|00000bf0| 63 61 63 68 65 20 6d 61 | 6e 61 67 65 72 0a 20 20 |cache ma|nager. |
|00000c00| 5b 5b 73 65 6c 66 20 6c | 6f 63 61 6c 46 6f 6c 64 |[[self l|ocalFold|
|00000c10| 65 72 43 61 63 68 65 4d | 61 6e 61 67 65 72 5d 20 |erCacheM|anager] |
|00000c20| 73 65 74 50 61 74 68 54 | 6f 46 6f 6c 64 65 72 3a |setPathT|oFolder:|
|00000c30| 20 5b 73 65 6c 66 20 70 | 61 74 68 5d 5d 3b 0a 20 | [self p|ath]];. |
|00000c40| 20 0a 20 20 2f 2f 4e 53 | 44 65 62 75 67 4c 6f 67 | . //NS|DebugLog|
|00000c50| 28 40 22 46 6f 6c 64 65 | 72 20 28 25 40 29 20 6f |(@"Folde|r (%@) o|
|00000c60| 70 65 6e 65 64 2e 2e 2e | 22 2c 20 5b 73 65 6c 66 |pened...|", [self|
|00000c70| 20 70 61 74 68 5d 29 3b | 0a 0a 20 20 72 65 74 75 | path]);|.. retu|
|00000c80| 72 6e 20 73 65 6c 66 3b | 0a 7d 0a 0a 2f 2f 0a 2f |rn self;|.}..//./|
|00000c90| 2f 0a 2f 2f 0a 2d 20 28 | 76 6f 69 64 29 20 64 65 |/.//.- (|void) de|
|00000ca0| 61 6c 6c 6f 63 0a 7b 0a | 20 20 52 45 4c 45 41 53 |alloc.{.| RELEAS|
|00000cb0| 45 28 66 69 6c 65 41 74 | 74 72 69 62 75 74 65 73 |E(fileAt|tributes|
|00000cc0| 29 3b 0a 20 20 52 45 4c | 45 41 53 45 28 70 61 74 |);. REL|EASE(pat|
|00000cd0| 68 29 3b 0a 20 20 0a 20 | 20 54 45 53 54 5f 52 45 |h);. . | TEST_RE|
|00000ce0| 4c 45 41 53 45 28 6c 6f | 63 61 6c 46 6f 6c 64 65 |LEASE(lo|calFolde|
|00000cf0| 72 43 61 63 68 65 4d 61 | 6e 61 67 65 72 29 3b 0a |rCacheMa|nager);.|
|00000d00| 0a 20 20 5b 73 75 70 65 | 72 20 64 65 61 6c 6c 6f |. [supe|r deallo|
|00000d10| 63 5d 3b 0a 7d 0a 0a 2f | 2f 0a 2f 2f 20 54 68 69 |c];.}../|/.// Thi|
|00000d20| 73 20 6d 65 74 68 6f 64 | 20 69 73 20 75 73 65 64 |s method| is used|
|00000d30| 20 74 6f 20 70 61 72 73 | 65 20 74 68 65 20 6d 65 | to pars|e the me|
|00000d40| 73 73 61 67 65 20 68 65 | 61 64 65 72 73 20 28 61 |ssage he|aders (a|
|00000d50| 6e 64 20 6f 6e 6c 79 20 | 74 68 61 74 29 0a 2f 2f |nd only |that).//|
|00000d60| 20 66 72 6f 6d 20 74 68 | 65 20 63 75 72 72 65 6e | from th|e curren|
|00000d70| 74 20 66 6f 6c 64 65 72 | 2e 0a 2f 2f 0a 2d 20 28 |t folder|..//.- (|
|00000d80| 76 6f 69 64 29 20 70 61 | 72 73 65 0a 7b 0a 20 20 |void) pa|rse.{. |
|00000d90| 4c 6f 63 61 6c 4d 65 73 | 73 61 67 65 20 2a 61 4c |LocalMes|sage *aL|
|00000da0| 6f 63 61 6c 4d 65 73 73 | 61 67 65 3b 0a 20 20 4e |ocalMess|age;. N|
|00000db0| 53 41 75 74 6f 72 65 6c | 65 61 73 65 50 6f 6f 6c |SAutorel|easePool|
|00000dc0| 20 2a 70 6f 6f 6c 3b 0a | 20 20 0a 20 20 6c 6f 6e | *pool;.| . lon|
|00000dd0| 67 20 62 65 67 69 6e 2c | 20 65 6e 64 2c 20 73 69 |g begin,| end, si|
|00000de0| 7a 65 3b 0a 20 20 63 68 | 61 72 20 61 4c 69 6e 65 |ze;. ch|ar aLine|
|00000df0| 5b 31 30 32 34 5d 3b 0a | 20 20 69 6e 74 20 69 6e |[1024];.| int in|
|00000e00| 64 65 78 3b 0a 20 20 0a | 20 20 2f 2f 0a 20 20 2f |dex;. .| //. /|
|00000e10| 2f 20 57 65 20 66 69 72 | 73 74 20 76 65 72 69 66 |/ We fir|st verif|
|00000e20| 79 20 69 66 20 77 65 20 | 6e 65 65 64 20 74 6f 20 |y if we |need to |
|00000e30| 70 61 72 73 65 20 74 68 | 65 20 66 6f 6c 64 65 72 |parse th|e folder|
|00000e40| 2e 0a 20 20 2f 2f 20 57 | 65 20 69 6e 76 61 6c 69 |.. // W|e invali|
|00000e50| 64 61 74 65 20 6f 75 72 | 20 63 61 63 68 65 20 69 |date our| cache i|
|00000e60| 66 20 6f 75 72 20 73 69 | 7a 65 20 4f 52 20 6f 72 |f our si|ze OR or|
|00000e70| 20 6d 6f 64 69 66 69 63 | 61 74 69 6f 6e 20 64 61 | modific|ation da|
|00000e80| 74 65 20 68 61 76 65 20 | 63 68 61 6e 67 65 64 0a |te have |changed.|
|00000e90| 20 20 2f 2f 0a 20 20 69 | 66 20 28 20 5b 5b 5b 73 | //. i|f ( [[[s|
|00000ea0| 65 6c 66 20 66 69 6c 65 | 41 74 74 72 69 62 75 74 |elf file|Attribut|
|00000eb0| 65 73 5d 20 6f 62 6a 65 | 63 74 46 6f 72 4b 65 79 |es] obje|ctForKey|
|00000ec0| 3a 20 4e 53 46 69 6c 65 | 4d 6f 64 69 66 69 63 61 |: NSFile|Modifica|
|00000ed0| 74 69 6f 6e 44 61 74 65 | 5d 20 69 73 45 71 75 61 |tionDate|] isEqua|
|00000ee0| 6c 54 6f 44 61 74 65 3a | 20 5b 5b 73 65 6c 66 20 |lToDate:| [[self |
|00000ef0| 6c 6f 63 61 6c 46 6f 6c | 64 65 72 43 61 63 68 65 |localFol|derCache|
|00000f00| 4d 61 6e 61 67 65 72 5d | 20 6d 6f 64 69 66 69 63 |Manager]| modific|
|00000f10| 61 74 69 6f 6e 44 61 74 | 65 5d 5d 20 7c 7c 0a 20 |ationDat|e]] ||. |
|00000f20| 20 20 20 20 20 20 5b 5b | 5b 73 65 6c 66 20 66 69 | [[|[self fi|
|00000f30| 6c 65 41 74 74 72 69 62 | 75 74 65 73 5d 20 6f 62 |leAttrib|utes] ob|
|00000f40| 6a 65 63 74 46 6f 72 4b | 65 79 3a 20 4e 53 46 69 |jectForK|ey: NSFi|
|00000f50| 6c 65 53 69 7a 65 5d 20 | 69 6e 74 56 61 6c 75 65 |leSize] |intValue|
|00000f60| 5d 20 3d 3d 20 5b 5b 73 | 65 6c 66 20 6c 6f 63 61 |] == [[s|elf loca|
|00000f70| 6c 46 6f 6c 64 65 72 43 | 61 63 68 65 4d 61 6e 61 |lFolderC|acheMana|
|00000f80| 67 65 72 5d 20 66 69 6c | 65 53 69 7a 65 5d 20 29 |ger] fil|eSize] )|
|00000f90| 0a 20 20 20 20 7b 0a 20 | 20 20 20 20 20 4e 53 41 |. {. | NSA|
|00000fa0| 72 72 61 79 20 2a 61 72 | 72 61 79 3b 0a 20 20 20 |rray *ar|ray;. |
|00000fb0| 20 20 20 69 6e 74 20 69 | 3b 0a 20 20 20 20 20 20 | int i|;. |
|00000fc0| 0a 20 20 20 20 20 20 4e | 53 44 65 62 75 67 4c 6f |. N|SDebugLo|
|00000fd0| 67 28 40 22 55 73 69 6e | 67 20 63 61 63 68 65 20 |g(@"Usin|g cache |
|00000fe0| 66 6f 72 20 66 6f 6c 64 | 65 72 20 25 40 22 2c 20 |for fold|er %@", |
|00000ff0| 5b 73 65 6c 66 20 6e 61 | 6d 65 5d 29 3b 0a 20 20 |[self na|me]);. |
|00001000| 20 20 20 20 0a 20 20 20 | 20 20 20 61 72 72 61 79 | . | array|
|00001010| 20 3d 20 5b 5b 73 65 6c | 66 20 6c 6f 63 61 6c 46 | = [[sel|f localF|
|00001020| 6f 6c 64 65 72 43 61 63 | 68 65 4d 61 6e 61 67 65 |olderCac|heManage|
|00001030| 72 5d 20 6d 65 73 73 61 | 67 65 73 5d 3b 0a 20 20 |r] messa|ges];. |
|00001040| 20 20 20 20 0a 20 20 20 | 20 20 20 66 6f 72 20 28 | . | for (|
|00001050| 69 20 3d 20 30 3b 20 69 | 20 3c 20 5b 61 72 72 61 |i = 0; i| < [arra|
|00001060| 79 20 63 6f 75 6e 74 5d | 3b 20 69 2b 2b 29 0a 09 |y count]|; i++)..|
|00001070| 7b 0a 09 20 20 5b 5b 61 | 72 72 61 79 20 6f 62 6a |{.. [[a|rray obj|
|00001080| 65 63 74 41 74 49 6e 64 | 65 78 3a 20 69 5d 20 73 |ectAtInd|ex: i] s|
|00001090| 65 74 46 6f 6c 64 65 72 | 3a 20 73 65 6c 66 5d 3b |etFolder|: self];|
|000010a0| 0a 09 7d 0a 20 20 20 20 | 20 20 0a 20 20 20 20 20 |..}. | . |
|000010b0| 20 5b 73 65 6c 66 20 73 | 65 74 4d 65 73 73 61 67 | [self s|etMessag|
|000010c0| 65 73 3a 20 61 72 72 61 | 79 5d 3b 0a 0a 20 20 20 |es: arra|y];.. |
|000010d0| 20 20 20 72 65 74 75 72 | 6e 3b 0a 20 20 20 20 7d | retur|n;. }|
|000010e0| 0a 20 20 65 6c 73 65 0a | 20 20 20 20 7b 0a 20 20 |. else.| {. |
|000010f0| 20 20 20 20 4e 53 44 65 | 62 75 67 4c 6f 67 28 40 | NSDe|bugLog(@|
|00001100| 22 49 6e 76 61 6c 69 64 | 61 74 69 6e 67 20 63 61 |"Invalid|ating ca|
|00001110| 63 68 65 2e 22 29 3b 0a | 20 20 20 20 20 20 5b 5b |che.");.| [[|
|00001120| 73 65 6c 66 20 6c 6f 63 | 61 6c 46 6f 6c 64 65 72 |self loc|alFolder|
|00001130| 43 61 63 68 65 4d 61 6e | 61 67 65 72 5d 20 69 6e |CacheMan|ager] in|
|00001140| 76 61 6c 69 64 61 74 65 | 5d 3b 0a 20 20 20 20 7d |validate|];. }|
|00001150| 0a 20 20 0a 20 20 4e 53 | 44 65 62 75 67 4c 6f 67 |. . NS|DebugLog|
|00001160| 28 40 22 52 65 62 75 69 | 6c 64 69 6e 67 20 63 61 |(@"Rebui|lding ca|
|00001170| 63 68 65 20 66 6f 72 20 | 66 6f 6c 64 65 72 20 25 |che for |folder %|
|00001180| 40 22 2c 20 5b 73 65 6c | 66 20 6e 61 6d 65 5d 29 |@", [sel|f name])|
|00001190| 3b 0a 20 20 4e 53 44 65 | 62 75 67 4c 6f 67 28 40 |;. NSDe|bugLog(@|
|000011a0| 22 50 4c 45 41 53 45 2c | 20 42 45 20 50 41 54 49 |"PLEASE,| BE PATI|
|000011b0| 45 4e 54 21 22 29 3b 0a | 0a 20 20 2f 2f 20 57 65 |ENT!");.|. // We|
|000011c0| 20 63 72 65 61 74 65 20 | 61 20 74 65 6d 70 6f 72 | create |a tempor|
|000011d0| 61 72 79 20 61 75 74 6f | 72 65 6c 65 61 73 65 20 |ary auto|release |
|000011e0| 70 6f 6f 6c 20 73 69 6e | 63 65 20 70 61 72 73 65 |pool sin|ce parse|
|000011f0| 20 63 61 6e 20 62 65 0a | 20 20 2f 2f 20 6d 65 6d | can be.| // mem|
|00001200| 6f 72 79 20 63 6f 6e 73 | 75 6d 69 6e 67 20 6f 6e |ory cons|uming on|
|00001210| 20 6f 75 72 20 64 65 66 | 61 75 6c 74 20 61 75 74 | our def|ault aut|
|00001220| 6f 72 65 6c 65 61 73 65 | 20 70 6f 6f 6c 2e 0a 20 |orelease| pool.. |
|00001230| 20 70 6f 6f 6c 20 3d 20 | 5b 5b 4e 53 41 75 74 6f | pool = |[[NSAuto|
|00001240| 72 65 6c 65 61 73 65 50 | 6f 6f 6c 20 61 6c 6c 6f |releaseP|ool allo|
|00001250| 63 5d 20 69 6e 69 74 5d | 3b 0a 0a 20 20 2f 2f 20 |c] init]|;.. // |
|00001260| 57 65 20 69 6e 69 74 69 | 61 6c 69 7a 65 20 6f 75 |We initi|alize ou|
|00001270| 72 20 76 61 72 69 61 62 | 6c 65 73 0a 20 20 61 4c |r variab|les. aL|
|00001280| 6f 63 61 6c 4d 65 73 73 | 61 67 65 20 3d 20 5b 5b |ocalMess|age = [[|
|00001290| 4c 6f 63 61 6c 4d 65 73 | 73 61 67 65 20 61 6c 6c |LocalMes|sage all|
|000012a0| 6f 63 5d 20 69 6e 69 74 | 5d 3b 0a 20 20 62 65 67 |oc] init|];. beg|
|000012b0| 69 6e 20 3d 20 66 74 65 | 6c 6c 28 73 74 72 65 61 |in = fte|ll(strea|
|000012c0| 6d 29 3b 0a 20 20 65 6e | 64 20 3d 20 30 4c 3b 0a |m);. en|d = 0L;.|
|000012d0| 20 20 69 6e 64 65 78 20 | 3d 20 30 3b 0a 20 20 0a | index |= 0;. .|
|000012e0| 20 20 77 68 69 6c 65 20 | 28 66 67 65 74 73 28 61 | while |(fgets(a|
|000012f0| 4c 69 6e 65 2c 20 31 30 | 32 34 2c 20 73 74 72 65 |Line, 10|24, stre|
|00001300| 61 6d 29 20 21 3d 20 4e | 55 4c 4c 29 0a 20 20 20 |am) != N|ULL). |
|00001310| 20 7b 0a 20 20 20 20 20 | 20 73 77 69 74 63 68 28 | {. | switch(|
|00001320| 20 74 6f 6c 6f 77 65 72 | 28 61 4c 69 6e 65 5b 30 | tolower|(aLine[0|
|00001330| 5d 29 20 29 0a 09 7b 20 | 0a 09 63 61 73 65 20 27 |]) )..{ |..case '|
|00001340| 62 27 3a 0a 09 20 20 69 | 66 20 28 73 74 72 6e 63 |b':.. i|f (strnc|
|00001350| 61 73 65 63 6d 70 28 61 | 4c 69 6e 65 2c 20 22 42 |asecmp(a|Line, "B|
|00001360| 63 63 22 2c 20 33 29 20 | 3d 3d 20 30 29 0a 09 20 |cc", 3) |== 0).. |
|00001370| 20 20 20 7b 0a 09 20 20 | 20 20 20 20 5b 50 61 72 | {.. | [Par|
|00001380| 73 65 72 20 70 61 72 73 | 65 44 65 73 74 69 6e 61 |ser pars|eDestina|
|00001390| 74 69 6f 6e 3a 20 5b 73 | 65 6c 66 20 75 6e 66 6f |tion: [s|elf unfo|
|000013a0| 6c 64 4c 69 6e 65 73 53 | 74 61 72 74 69 6e 67 57 |ldLinesS|tartingW|
|000013b0| 69 74 68 3a 20 61 4c 69 | 6e 65 5d 0a 09 20 20 20 |ith: aLi|ne].. |
|000013c0| 20 20 20 09 20 20 20 20 | 20 20 66 6f 72 54 79 70 | . | forTyp|
|000013d0| 65 3a 20 42 43 43 0a 09 | 20 20 20 20 20 20 09 20 |e: BCC..| . |
|000013e0| 20 20 20 20 20 69 6e 4d | 65 73 73 61 67 65 3a 20 | inM|essage: |
|000013f0| 61 4c 6f 63 61 6c 4d 65 | 73 73 61 67 65 5d 3b 0a |aLocalMe|ssage];.|
|00001400| 09 20 20 20 20 7d 0a 09 | 20 20 65 6c 73 65 0a 09 |. }..| else..|
|00001410| 20 20 20 20 7b 0a 09 20 | 20 20 20 20 20 5b 50 61 | {.. | [Pa|
|00001420| 72 73 65 72 20 70 61 72 | 73 65 55 6e 6b 6e 6f 77 |rser par|seUnknow|
|00001430| 6e 48 65 61 64 65 72 3a | 20 5b 73 65 6c 66 20 75 |nHeader:| [self u|
|00001440| 6e 66 6f 6c 64 4c 69 6e | 65 73 53 74 61 72 74 69 |nfoldLin|esStarti|
|00001450| 6e 67 57 69 74 68 3a 20 | 61 4c 69 6e 65 5d 0a 09 |ngWith: |aLine]..|
|00001460| 20 20 20 20 20 20 09 20 | 20 20 20 20 20 69 6e 4d | . | inM|
|00001470| 65 73 73 61 67 65 3a 20 | 61 4c 6f 63 61 6c 4d 65 |essage: |aLocalMe|
|00001480| 73 73 61 67 65 5d 3b 0a | 09 20 20 20 20 7d 0a 09 |ssage];.|. }..|
|00001490| 20 20 62 72 65 61 6b 3b | 0a 09 20 20 0a 09 63 61 | break;|.. ..ca|
|000014a0| 73 65 20 27 63 27 3a 0a | 09 20 20 69 66 20 28 73 |se 'c':.|. if (s|
|000014b0| 74 72 6e 63 61 73 65 63 | 6d 70 28 61 4c 69 6e 65 |trncasec|mp(aLine|
|000014c0| 2c 20 22 43 63 22 2c 20 | 32 29 20 3d 3d 20 30 29 |, "Cc", |2) == 0)|
|000014d0| 0a 09 20 20 20 20 7b 0a | 09 20 20 20 20 20 20 5b |.. {.|. [|
|000014e0| 50 61 72 73 65 72 20 70 | 61 72 73 65 44 65 73 74 |Parser p|arseDest|
|000014f0| 69 6e 61 74 69 6f 6e 3a | 20 5b 73 65 6c 66 20 75 |ination:| [self u|
|00001500| 6e 66 6f 6c 64 4c 69 6e | 65 73 53 74 61 72 74 69 |nfoldLin|esStarti|
|00001510| 6e 67 57 69 74 68 3a 20 | 61 4c 69 6e 65 5d 0a 09 |ngWith: |aLine]..|
|00001520| 20 20 20 20 20 20 09 20 | 20 20 20 20 20 66 6f 72 | . | for|
|00001530| 54 79 70 65 3a 20 43 43 | 0a 09 20 20 20 20 20 20 |Type: CC|.. |
|00001540| 09 20 20 20 20 20 20 69 | 6e 4d 65 73 73 61 67 65 |. i|nMessage|
|00001550| 3a 20 61 4c 6f 63 61 6c | 4d 65 73 73 61 67 65 5d |: aLocal|Message]|
|00001560| 3b 0a 09 20 20 20 20 7d | 0a 09 20 20 65 6c 73 65 |;.. }|.. else|
|00001570| 20 69 66 20 28 73 74 72 | 6e 63 61 73 65 63 6d 70 | if (str|ncasecmp|
|00001580| 28 61 4c 69 6e 65 2c 20 | 22 43 6f 6e 74 65 6e 74 |(aLine, |"Content|
|00001590| 2d 44 69 73 70 6f 73 69 | 74 69 6f 6e 22 2c 20 31 |-Disposi|tion", 1|
|000015a0| 39 29 20 3d 3d 20 30 29 | 0a 09 20 20 20 20 7b 0a |9) == 0)|.. {.|
|000015b0| 09 20 20 20 20 20 20 5b | 50 61 72 73 65 72 20 70 |. [|Parser p|
|000015c0| 61 72 73 65 43 6f 6e 74 | 65 6e 74 44 69 73 70 6f |arseCont|entDispo|
|000015d0| 73 69 74 69 6f 6e 3a 20 | 5b 73 65 6c 66 20 75 6e |sition: |[self un|
|000015e0| 66 6f 6c 64 4c 69 6e 65 | 73 53 74 61 72 74 69 6e |foldLine|sStartin|
|000015f0| 67 57 69 74 68 3a 20 61 | 4c 69 6e 65 5d 0a 09 20 |gWith: a|Line].. |
|00001600| 20 20 20 20 20 09 20 20 | 20 20 20 20 69 6e 50 61 | . | inPa|
|00001610| 72 74 3a 20 61 4c 6f 63 | 61 6c 4d 65 73 73 61 67 |rt: aLoc|alMessag|
|00001620| 65 5d 3b 0a 09 20 20 20 | 20 7d 0a 09 20 20 65 6c |e];.. | }.. el|
|00001630| 73 65 20 69 66 20 28 73 | 74 72 6e 63 61 73 65 63 |se if (s|trncasec|
|00001640| 6d 70 28 61 4c 69 6e 65 | 2c 20 22 43 6f 6e 74 65 |mp(aLine|, "Conte|
|00001650| 6e 74 2d 54 72 61 6e 73 | 66 65 72 2d 45 6e 63 6f |nt-Trans|fer-Enco|
|00001660| 64 69 6e 67 22 2c 20 32 | 35 29 20 3d 3d 20 30 29 |ding", 2|5) == 0)|
|00001670| 0a 09 20 20 20 20 7b 0a | 09 20 20 20 20 20 20 5b |.. {.|. [|
|00001680| 50 61 72 73 65 72 20 70 | 61 72 73 65 43 6f 6e 74 |Parser p|arseCont|
|00001690| 65 6e 74 54 72 61 6e 73 | 66 65 72 45 6e 63 6f 64 |entTrans|ferEncod|
|000016a0| 69 6e 67 3a 20 5b 73 65 | 6c 66 20 75 6e 66 6f 6c |ing: [se|lf unfol|
|000016b0| 64 4c 69 6e 65 73 53 74 | 61 72 74 69 6e 67 57 69 |dLinesSt|artingWi|
|000016c0| 74 68 3a 20 61 4c 69 6e | 65 5d 0a 09 09 20 20 20 |th: aLin|e]... |
|000016d0| 20 20 20 69 6e 50 61 72 | 74 3a 20 61 4c 6f 63 61 | inPar|t: aLoca|
|000016e0| 6c 4d 65 73 73 61 67 65 | 5d 3b 0a 09 20 20 20 20 |lMessage|];.. |
|000016f0| 7d 0a 09 20 20 65 6c 73 | 65 20 69 66 20 28 73 74 |}.. els|e if (st|
|00001700| 72 6e 63 61 73 65 63 6d | 70 28 61 4c 69 6e 65 2c |rncasecm|p(aLine,|
|00001710| 20 22 43 6f 6e 74 65 6e | 74 2d 54 79 70 65 22 2c | "Conten|t-Type",|
|00001720| 20 31 32 29 20 3d 3d 20 | 30 29 0a 09 20 20 20 20 | 12) == |0).. |
|00001730| 7b 0a 09 20 20 20 20 20 | 20 5b 50 61 72 73 65 72 |{.. | [Parser|
|00001740| 20 70 61 72 73 65 43 6f | 6e 74 65 6e 74 54 79 70 | parseCo|ntentTyp|
|00001750| 65 3a 20 5b 73 65 6c 66 | 20 75 6e 66 6f 6c 64 4c |e: [self| unfoldL|
|00001760| 69 6e 65 73 53 74 61 72 | 74 69 6e 67 57 69 74 68 |inesStar|tingWith|
|00001770| 3a 20 61 4c 69 6e 65 5d | 0a 09 20 20 20 20 20 20 |: aLine]|.. |
|00001780| 09 20 20 20 20 20 20 69 | 6e 50 61 72 74 3a 20 61 |. i|nPart: a|
|00001790| 4c 6f 63 61 6c 4d 65 73 | 73 61 67 65 5d 3b 0a 09 |LocalMes|sage];..|
|000017a0| 20 20 20 20 7d 0a 09 20 | 20 65 6c 73 65 0a 09 20 | }.. | else.. |
|000017b0| 20 20 20 7b 0a 09 20 20 | 20 20 20 20 5b 50 61 72 | {.. | [Par|
|000017c0| 73 65 72 20 70 61 72 73 | 65 55 6e 6b 6e 6f 77 6e |ser pars|eUnknown|
|000017d0| 48 65 61 64 65 72 3a 20 | 5b 73 65 6c 66 20 75 6e |Header: |[self un|
|000017e0| 66 6f 6c 64 4c 69 6e 65 | 73 53 74 61 72 74 69 6e |foldLine|sStartin|
|000017f0| 67 57 69 74 68 3a 20 61 | 4c 69 6e 65 5d 0a 09 20 |gWith: a|Line].. |
|00001800| 20 20 20 20 20 09 20 20 | 20 20 20 20 69 6e 4d 65 | . | inMe|
|00001810| 73 73 61 67 65 3a 20 61 | 4c 6f 63 61 6c 4d 65 73 |ssage: a|LocalMes|
|00001820| 73 61 67 65 5d 3b 0a 09 | 20 20 20 20 7d 0a 09 20 |sage];..| }.. |
|00001830| 20 62 72 65 61 6b 3b 0a | 09 20 20 0a 09 63 61 73 | break;.|. ..cas|
|00001840| 65 20 27 64 27 3a 0a 09 | 20 20 69 66 20 28 73 74 |e 'd':..| if (st|
|00001850| 72 6e 63 61 73 65 63 6d | 70 28 61 4c 69 6e 65 2c |rncasecm|p(aLine,|
|00001860| 20 22 44 61 74 65 22 2c | 20 34 29 20 3d 3d 20 30 | "Date",| 4) == 0|
|00001870| 29 0a 09 20 20 20 20 7b | 0a 09 20 20 20 20 20 20 |).. {|.. |
|00001880| 5b 50 61 72 73 65 72 20 | 70 61 72 73 65 44 61 74 |[Parser |parseDat|
|00001890| 65 3a 20 5b 73 65 6c 66 | 20 75 6e 66 6f 6c 64 4c |e: [self| unfoldL|
|000018a0| 69 6e 65 73 53 74 61 72 | 74 69 6e 67 57 69 74 68 |inesStar|tingWith|
|000018b0| 3a 20 61 4c 69 6e 65 5d | 0a 09 20 20 20 20 20 20 |: aLine]|.. |
|000018c0| 09 20 20 20 20 20 20 69 | 6e 4d 65 73 73 61 67 65 |. i|nMessage|
|000018d0| 3a 20 61 4c 6f 63 61 6c | 4d 65 73 73 61 67 65 5d |: aLocal|Message]|
|000018e0| 3b 0a 09 20 20 20 20 7d | 0a 09 20 20 65 6c 73 65 |;.. }|.. else|
|000018f0| 0a 09 20 20 20 20 7b 0a | 09 20 20 20 20 20 20 5b |.. {.|. [|
|00001900| 50 61 72 73 65 72 20 70 | 61 72 73 65 55 6e 6b 6e |Parser p|arseUnkn|
|00001910| 6f 77 6e 48 65 61 64 65 | 72 3a 20 5b 73 65 6c 66 |ownHeade|r: [self|
|00001920| 20 75 6e 66 6f 6c 64 4c | 69 6e 65 73 53 74 61 72 | unfoldL|inesStar|
|00001930| 74 69 6e 67 57 69 74 68 | 3a 20 61 4c 69 6e 65 5d |tingWith|: aLine]|
|00001940| 0a 09 20 20 20 20 20 20 | 09 20 20 20 20 20 20 69 |.. |. i|
|00001950| 6e 4d 65 73 73 61 67 65 | 3a 20 61 4c 6f 63 61 6c |nMessage|: aLocal|
|00001960| 4d 65 73 73 61 67 65 5d | 3b 0a 09 20 20 20 20 7d |Message]|;.. }|
|00001970| 0a 09 20 20 62 72 65 61 | 6b 3b 0a 0a 09 63 61 73 |.. brea|k;...cas|
|00001980| 65 20 27 66 27 3a 0a 09 | 20 20 69 66 20 28 73 74 |e 'f':..| if (st|
|00001990| 72 6e 63 61 73 65 63 6d | 70 28 61 4c 69 6e 65 2c |rncasecm|p(aLine,|
|000019a0| 20 22 46 72 6f 6d 20 22 | 2c 20 35 29 20 3d 3d 20 | "From "|, 5) == |
|000019b0| 30 29 0a 09 20 20 20 20 | 7b 0a 09 20 20 20 20 20 |0).. |{.. |
|000019c0| 20 2f 2f 20 64 6f 20 6e | 6f 74 68 69 6e 67 2c 20 | // do n|othing, |
|000019d0| 69 74 27 73 20 6f 75 72 | 20 6d 65 73 73 61 67 65 |it's our| message|
|000019e0| 20 73 65 70 61 72 61 74 | 6f 72 0a 09 20 20 20 20 | separat|or.. |
|000019f0| 7d 0a 09 20 20 65 6c 73 | 65 20 69 66 20 28 73 74 |}.. els|e if (st|
|00001a00| 72 6e 63 61 73 65 63 6d | 70 28 61 4c 69 6e 65 2c |rncasecm|p(aLine,|
|00001a10| 20 22 46 72 6f 6d 22 2c | 20 34 29 20 3d 3d 20 30 | "From",| 4) == 0|
|00001a20| 29 0a 09 20 20 20 20 7b | 0a 09 20 20 20 20 20 20 |).. {|.. |
|00001a30| 5b 50 61 72 73 65 72 20 | 70 61 72 73 65 46 72 6f |[Parser |parseFro|
|00001a40| 6d 3a 20 5b 73 65 6c 66 | 20 75 6e 66 6f 6c 64 4c |m: [self| unfoldL|
|00001a50| 69 6e 65 73 53 74 61 72 | 74 69 6e 67 57 69 74 68 |inesStar|tingWith|
|00001a60| 3a 20 61 4c 69 6e 65 5d | 0a 09 20 20 20 20 20 20 |: aLine]|.. |
|00001a70| 09 20 20 20 20 20 20 69 | 6e 4d 65 73 73 61 67 65 |. i|nMessage|
|00001a80| 3a 20 61 4c 6f 63 61 6c | 4d 65 73 73 61 67 65 5d |: aLocal|Message]|
|00001a90| 3b 0a 09 20 20 20 20 7d | 0a 09 20 20 65 6c 73 65 |;.. }|.. else|
|00001aa0| 0a 09 20 20 20 20 7b 0a | 09 20 20 20 20 20 20 5b |.. {.|. [|
|00001ab0| 50 61 72 73 65 72 20 70 | 61 72 73 65 55 6e 6b 6e |Parser p|arseUnkn|
|00001ac0| 6f 77 6e 48 65 61 64 65 | 72 3a 20 5b 73 65 6c 66 |ownHeade|r: [self|
|00001ad0| 20 75 6e 66 6f 6c 64 4c | 69 6e 65 73 53 74 61 72 | unfoldL|inesStar|
|00001ae0| 74 69 6e 67 57 69 74 68 | 3a 20 61 4c 69 6e 65 5d |tingWith|: aLine]|
|00001af0| 0a 09 20 20 20 20 20 20 | 09 20 20 20 20 20 20 69 |.. |. i|
|00001b00| 6e 4d 65 73 73 61 67 65 | 3a 20 61 4c 6f 63 61 6c |nMessage|: aLocal|
|00001b10| 4d 65 73 73 61 67 65 5d | 3b 0a 09 20 20 20 20 7d |Message]|;.. }|
|00001b20| 0a 09 20 20 62 72 65 61 | 6b 3b 0a 0a 09 63 61 73 |.. brea|k;...cas|
|00001b30| 65 20 27 6d 27 3a 0a 09 | 20 20 69 66 20 28 73 74 |e 'm':..| if (st|
|00001b40| 72 6e 63 61 73 65 63 6d | 70 28 61 4c 69 6e 65 2c |rncasecm|p(aLine,|
|00001b50| 20 22 4d 65 73 73 61 67 | 65 2d 49 44 22 2c 20 31 | "Messag|e-ID", 1|
|00001b60| 30 29 20 3d 3d 20 30 29 | 0a 09 20 20 20 20 7b 0a |0) == 0)|.. {.|
|00001b70| 09 20 20 20 20 20 20 5b | 50 61 72 73 65 72 20 70 |. [|Parser p|
|00001b80| 61 72 73 65 4d 65 73 73 | 61 67 65 49 44 3a 20 5b |arseMess|ageID: [|
|00001b90| 73 65 6c 66 20 75 6e 66 | 6f 6c 64 4c 69 6e 65 73 |self unf|oldLines|
|00001ba0| 53 74 61 72 74 69 6e 67 | 57 69 74 68 3a 20 61 4c |Starting|With: aL|
|00001bb0| 69 6e 65 5d 0a 09 20 20 | 20 20 20 20 09 20 20 20 |ine].. | . |
|00001bc0| 20 20 20 69 6e 4d 65 73 | 73 61 67 65 3a 20 61 4c | inMes|sage: aL|
|00001bd0| 6f 63 61 6c 4d 65 73 73 | 61 67 65 5d 3b 0a 09 20 |ocalMess|age];.. |
|00001be0| 20 20 20 7d 0a 09 20 20 | 65 6c 73 65 20 69 66 20 | }.. |else if |
|00001bf0| 28 73 74 72 6e 63 61 73 | 65 63 6d 70 28 61 4c 69 |(strncas|ecmp(aLi|
|00001c00| 6e 65 2c 20 22 4d 49 4d | 45 2d 56 65 72 73 69 6f |ne, "MIM|E-Versio|
|00001c10| 6e 22 2c 20 31 32 29 20 | 3d 3d 20 30 29 0a 09 20 |n", 12) |== 0).. |
|00001c20| 20 20 20 7b 0a 09 20 20 | 20 20 20 20 5b 50 61 72 | {.. | [Par|
|00001c30| 73 65 72 20 70 61 72 73 | 65 4d 69 6d 65 56 65 72 |ser pars|eMimeVer|
|00001c40| 73 69 6f 6e 3a 20 5b 73 | 65 6c 66 20 75 6e 66 6f |sion: [s|elf unfo|
|00001c50| 6c 64 4c 69 6e 65 73 53 | 74 61 72 74 69 6e 67 57 |ldLinesS|tartingW|
|00001c60| 69 74 68 3a 20 61 4c 69 | 6e 65 5d 0a 09 20 20 20 |ith: aLi|ne].. |
|00001c70| 20 20 20 09 20 20 20 20 | 20 20 69 6e 4d 65 73 73 | . | inMess|
|00001c80| 61 67 65 3a 20 61 4c 6f | 63 61 6c 4d 65 73 73 61 |age: aLo|calMessa|
|00001c90| 67 65 5d 3b 0a 09 20 20 | 20 20 7d 0a 09 20 20 65 |ge];.. | }.. e|
|00001ca0| 6c 73 65 0a 09 20 20 20 | 20 7b 0a 09 20 20 20 20 |lse.. | {.. |
|00001cb0| 20 20 5b 50 61 72 73 65 | 72 20 70 61 72 73 65 55 | [Parse|r parseU|
|00001cc0| 6e 6b 6e 6f 77 6e 48 65 | 61 64 65 72 3a 20 5b 73 |nknownHe|ader: [s|
|00001cd0| 65 6c 66 20 75 6e 66 6f | 6c 64 4c 69 6e 65 73 53 |elf unfo|ldLinesS|
|00001ce0| 74 61 72 74 69 6e 67 57 | 69 74 68 3a 20 61 4c 69 |tartingW|ith: aLi|
|00001cf0| 6e 65 5d 0a 09 20 20 20 | 20 20 20 09 20 20 20 20 |ne].. | . |
|00001d00| 20 20 69 6e 4d 65 73 73 | 61 67 65 3a 20 61 4c 6f | inMess|age: aLo|
|00001d10| 63 61 6c 4d 65 73 73 61 | 67 65 5d 3b 0a 09 20 20 |calMessa|ge];.. |
|00001d20| 20 20 7d 0a 09 20 20 62 | 72 65 61 6b 3b 0a 09 20 | }.. b|reak;.. |
|00001d30| 20 0a 09 63 61 73 65 20 | 27 6f 27 3a 0a 09 20 20 | ..case |'o':.. |
|00001d40| 69 66 20 28 73 74 72 6e | 63 61 73 65 63 6d 70 28 |if (strn|casecmp(|
|00001d50| 61 4c 69 6e 65 2c 20 22 | 4f 72 67 61 6e 69 7a 61 |aLine, "|Organiza|
|00001d60| 74 69 6f 6e 22 2c 20 31 | 32 29 20 3d 3d 20 30 29 |tion", 1|2) == 0)|
|00001d70| 0a 09 20 20 20 20 7b 0a | 09 20 20 20 20 20 20 5b |.. {.|. [|
|00001d80| 50 61 72 73 65 72 20 70 | 61 72 73 65 4f 72 67 61 |Parser p|arseOrga|
|00001d90| 6e 69 7a 61 74 69 6f 6e | 3a 20 5b 73 65 6c 66 20 |nization|: [self |
|00001da0| 75 6e 66 6f 6c 64 4c 69 | 6e 65 73 53 74 61 72 74 |unfoldLi|nesStart|
|00001db0| 69 6e 67 57 69 74 68 3a | 20 61 4c 69 6e 65 5d 0a |ingWith:| aLine].|
|00001dc0| 09 09 20 20 20 20 20 20 | 69 6e 4d 65 73 73 61 67 |.. |inMessag|
|00001dd0| 65 3a 20 61 4c 6f 63 61 | 6c 4d 65 73 73 61 67 65 |e: aLoca|lMessage|
|00001de0| 5d 3b 0a 09 20 20 20 20 | 7d 0a 09 20 20 65 6c 73 |];.. |}.. els|
|00001df0| 65 0a 09 20 20 20 20 7b | 0a 09 20 20 20 20 20 20 |e.. {|.. |
|00001e00| 5b 50 61 72 73 65 72 20 | 70 61 72 73 65 55 6e 6b |[Parser |parseUnk|
|00001e10| 6e 6f 77 6e 48 65 61 64 | 65 72 3a 20 5b 73 65 6c |nownHead|er: [sel|
|00001e20| 66 20 75 6e 66 6f 6c 64 | 4c 69 6e 65 73 53 74 61 |f unfold|LinesSta|
|00001e30| 72 74 69 6e 67 57 69 74 | 68 3a 20 61 4c 69 6e 65 |rtingWit|h: aLine|
|00001e40| 5d 0a 09 20 20 20 20 20 | 20 09 20 20 20 20 20 20 |].. | . |
|00001e50| 69 6e 4d 65 73 73 61 67 | 65 3a 20 61 4c 6f 63 61 |inMessag|e: aLoca|
|00001e60| 6c 4d 65 73 73 61 67 65 | 5d 3b 0a 09 20 20 20 20 |lMessage|];.. |
|00001e70| 7d 0a 09 20 20 62 72 65 | 61 6b 3b 0a 09 20 0a 09 |}.. bre|ak;.. ..|
|00001e80| 63 61 73 65 20 27 72 27 | 3a 0a 09 20 20 69 66 20 |case 'r'|:.. if |
|00001e90| 28 73 74 72 6e 63 61 73 | 65 63 6d 70 28 61 4c 69 |(strncas|ecmp(aLi|
|00001ea0| 6e 65 2c 20 22 52 65 70 | 6c 79 2d 54 6f 22 2c 20 |ne, "Rep|ly-To", |
|00001eb0| 38 29 20 3d 3d 20 30 29 | 0a 09 20 20 20 20 7b 0a |8) == 0)|.. {.|
|00001ec0| 09 20 20 20 20 20 20 5b | 50 61 72 73 65 72 20 70 |. [|Parser p|
|00001ed0| 61 72 73 65 52 65 70 6c | 79 54 6f 3a 20 5b 73 65 |arseRepl|yTo: [se|
|00001ee0| 6c 66 20 75 6e 66 6f 6c | 64 4c 69 6e 65 73 53 74 |lf unfol|dLinesSt|
|00001ef0| 61 72 74 69 6e 67 57 69 | 74 68 3a 20 61 4c 69 6e |artingWi|th: aLin|
|00001f00| 65 5d 0a 09 09 20 20 20 | 20 20 20 69 6e 4d 65 73 |e]... | inMes|
|00001f10| 73 61 67 65 3a 20 61 4c | 6f 63 61 6c 4d 65 73 73 |sage: aL|ocalMess|
|00001f20| 61 67 65 5d 3b 0a 09 20 | 20 20 20 7d 0a 09 20 20 |age];.. | }.. |
|00001f30| 65 6c 73 65 20 69 66 20 | 28 73 74 72 6e 63 61 73 |else if |(strncas|
|00001f40| 65 63 6d 70 28 61 4c 69 | 6e 65 2c 20 22 52 65 66 |ecmp(aLi|ne, "Ref|
|00001f50| 65 72 65 6e 63 65 73 22 | 2c 20 31 30 29 20 3d 3d |erences"|, 10) ==|
|00001f60| 20 30 29 0a 09 20 20 20 | 20 7b 0a 09 20 20 20 20 | 0).. | {.. |
|00001f70| 20 20 5b 50 61 72 73 65 | 72 20 70 61 72 73 65 52 | [Parse|r parseR|
|00001f80| 65 66 65 72 65 6e 63 65 | 73 3a 20 5b 73 65 6c 66 |eference|s: [self|
|00001f90| 20 75 6e 66 6f 6c 64 4c | 69 6e 65 73 53 74 61 72 | unfoldL|inesStar|
|00001fa0| 74 69 6e 67 57 69 74 68 | 3a 20 61 4c 69 6e 65 5d |tingWith|: aLine]|
|00001fb0| 0a 09 09 20 20 20 20 20 | 20 69 6e 4d 65 73 73 61 |... | inMessa|
|00001fc0| 67 65 3a 20 61 4c 6f 63 | 61 6c 4d 65 73 73 61 67 |ge: aLoc|alMessag|
|00001fd0| 65 5d 3b 0a 09 20 20 20 | 20 7d 20 0a 09 20 20 65 |e];.. | } .. e|
|00001fe0| 6c 73 65 0a 09 20 20 20 | 20 7b 0a 09 20 20 20 20 |lse.. | {.. |
|00001ff0| 20 20 5b 50 61 72 73 65 | 72 20 70 61 72 73 65 55 | [Parse|r parseU|
|00002000| 6e 6b 6e 6f 77 6e 48 65 | 61 64 65 72 3a 20 5b 73 |nknownHe|ader: [s|
|00002010| 65 6c 66 20 75 6e 66 6f | 6c 64 4c 69 6e 65 73 53 |elf unfo|ldLinesS|
|00002020| 74 61 72 74 69 6e 67 57 | 69 74 68 3a 20 61 4c 69 |tartingW|ith: aLi|
|00002030| 6e 65 5d 0a 09 20 20 20 | 20 20 20 09 20 20 20 20 |ne].. | . |
|00002040| 20 20 69 6e 4d 65 73 73 | 61 67 65 3a 20 61 4c 6f | inMess|age: aLo|
|00002050| 63 61 6c 4d 65 73 73 61 | 67 65 5d 3b 0a 09 20 20 |calMessa|ge];.. |
|00002060| 20 20 7d 0a 09 20 20 62 | 72 65 61 6b 3b 0a 0a 09 | }.. b|reak;...|
|00002070| 63 61 73 65 20 27 73 27 | 3a 0a 09 20 20 69 66 20 |case 's'|:.. if |
|00002080| 28 73 74 72 6e 63 61 73 | 65 63 6d 70 28 61 4c 69 |(strncas|ecmp(aLi|
|00002090| 6e 65 2c 20 22 53 74 61 | 74 75 73 22 2c 20 36 29 |ne, "Sta|tus", 6)|
|000020a0| 20 3d 3d 20 30 29 20 0a | 09 20 20 20 20 7b 0a 09 | == 0) .|. {..|
|000020b0| 20 20 20 20 20 20 5b 50 | 61 72 73 65 72 20 70 61 | [P|arser pa|
|000020c0| 72 73 65 53 74 61 74 75 | 73 3a 20 5b 73 65 6c 66 |rseStatu|s: [self|
|000020d0| 20 75 6e 66 6f 6c 64 4c | 69 6e 65 73 53 74 61 72 | unfoldL|inesStar|
|000020e0| 74 69 6e 67 57 69 74 68 | 3a 20 61 4c 69 6e 65 5d |tingWith|: aLine]|
|000020f0| 0a 09 20 20 20 20 20 20 | 09 20 20 20 20 20 20 69 |.. |. i|
|00002100| 6e 4d 65 73 73 61 67 65 | 3a 20 61 4c 6f 63 61 6c |nMessage|: aLocal|
|00002110| 4d 65 73 73 61 67 65 5d | 3b 0a 09 20 20 20 20 7d |Message]|;.. }|
|00002120| 0a 09 20 20 65 6c 73 65 | 20 69 66 20 28 73 74 72 |.. else| if (str|
|00002130| 6e 63 61 73 65 63 6d 70 | 28 61 4c 69 6e 65 2c 20 |ncasecmp|(aLine, |
|00002140| 22 53 75 62 6a 65 63 74 | 22 2c 20 37 29 20 3d 3d |"Subject|", 7) ==|
|00002150| 20 30 29 0a 09 20 20 20 | 20 7b 0a 09 20 20 20 20 | 0).. | {.. |
|00002160| 20 20 5b 50 61 72 73 65 | 72 20 70 61 72 73 65 53 | [Parse|r parseS|
|00002170| 75 62 6a 65 63 74 3a 20 | 5b 73 65 6c 66 20 75 6e |ubject: |[self un|
|00002180| 66 6f 6c 64 4c 69 6e 65 | 73 53 74 61 72 74 69 6e |foldLine|sStartin|
|00002190| 67 57 69 74 68 3a 20 61 | 4c 69 6e 65 5d 0a 09 20 |gWith: a|Line].. |
|000021a0| 20 20 20 20 20 09 20 20 | 20 20 20 20 69 6e 4d 65 | . | inMe|
|000021b0| 73 73 61 67 65 3a 20 61 | 4c 6f 63 61 6c 4d 65 73 |ssage: a|LocalMes|
|000021c0| 73 61 67 65 5d 3b 0a 09 | 20 20 20 20 7d 0a 09 20 |sage];..| }.. |
|000021d0| 20 65 6c 73 65 0a 09 20 | 20 20 20 7b 0a 09 20 20 | else.. | {.. |
|000021e0| 20 20 20 20 5b 50 61 72 | 73 65 72 20 70 61 72 73 | [Par|ser pars|
|000021f0| 65 55 6e 6b 6e 6f 77 6e | 48 65 61 64 65 72 3a 20 |eUnknown|Header: |
|00002200| 5b 73 65 6c 66 20 75 6e | 66 6f 6c 64 4c 69 6e 65 |[self un|foldLine|
|00002210| 73 53 74 61 72 74 69 6e | 67 57 69 74 68 3a 20 61 |sStartin|gWith: a|
|00002220| 4c 69 6e 65 5d 0a 09 20 | 20 20 20 20 20 09 20 20 |Line].. | . |
|00002230| 20 20 20 20 69 6e 4d 65 | 73 73 61 67 65 3a 20 61 | inMe|ssage: a|
|00002240| 4c 6f 63 61 6c 4d 65 73 | 73 61 67 65 5d 3b 0a 09 |LocalMes|sage];..|
|00002250| 20 20 20 20 7d 0a 09 20 | 20 62 72 65 61 6b 3b 0a | }.. | break;.|
|00002260| 0a 09 63 61 73 65 20 27 | 74 27 3a 0a 09 20 20 69 |..case '|t':.. i|
|00002270| 66 20 28 73 74 72 6e 63 | 61 73 65 63 6d 70 28 61 |f (strnc|asecmp(a|
|00002280| 4c 69 6e 65 2c 20 22 54 | 6f 22 2c 20 32 29 20 3d |Line, "T|o", 2) =|
|00002290| 3d 20 30 29 0a 09 20 20 | 20 20 7b 0a 09 20 20 20 |= 0).. | {.. |
|000022a0| 20 20 20 5b 50 61 72 73 | 65 72 20 70 61 72 73 65 | [Pars|er parse|
|000022b0| 44 65 73 74 69 6e 61 74 | 69 6f 6e 3a 20 5b 73 65 |Destinat|ion: [se|
|000022c0| 6c 66 20 75 6e 66 6f 6c | 64 4c 69 6e 65 73 53 74 |lf unfol|dLinesSt|
|000022d0| 61 72 74 69 6e 67 57 69 | 74 68 3a 20 61 4c 69 6e |artingWi|th: aLin|
|000022e0| 65 5d 0a 09 20 20 20 20 | 20 20 09 20 20 20 20 20 |e].. | . |
|000022f0| 20 66 6f 72 54 79 70 65 | 3a 20 54 4f 0a 09 20 20 | forType|: TO.. |
|00002300| 20 20 20 20 09 20 20 20 | 20 20 20 69 6e 4d 65 73 | . | inMes|
|00002310| 73 61 67 65 3a 20 61 4c | 6f 63 61 6c 4d 65 73 73 |sage: aL|ocalMess|
|00002320| 61 67 65 5d 3b 0a 09 20 | 20 20 20 7d 0a 09 20 20 |age];.. | }.. |
|00002330| 65 6c 73 65 0a 09 20 20 | 20 20 7b 0a 09 20 20 20 |else.. | {.. |
|00002340| 20 20 20 5b 50 61 72 73 | 65 72 20 70 61 72 73 65 | [Pars|er parse|
|00002350| 55 6e 6b 6e 6f 77 6e 48 | 65 61 64 65 72 3a 20 5b |UnknownH|eader: [|
|00002360| 73 65 6c 66 20 75 6e 66 | 6f 6c 64 4c 69 6e 65 73 |self unf|oldLines|
|00002370| 53 74 61 72 74 69 6e 67 | 57 69 74 68 3a 20 61 4c |Starting|With: aL|
|00002380| 69 6e 65 5d 0a 09 20 20 | 20 20 20 20 09 20 20 20 |ine].. | . |
|00002390| 20 20 20 69 6e 4d 65 73 | 73 61 67 65 3a 20 61 4c | inMes|sage: aL|
|000023a0| 6f 63 61 6c 4d 65 73 73 | 61 67 65 5d 3b 0a 09 20 |ocalMess|age];.. |
|000023b0| 20 20 20 7d 0a 09 20 20 | 62 72 65 61 6b 3b 0a 0a | }.. |break;..|
|000023c0| 09 63 61 73 65 20 27 78 | 27 3a 0a 09 20 20 69 66 |.case 'x|':.. if|
|000023d0| 20 28 73 74 72 6e 63 61 | 73 65 63 6d 70 28 61 4c | (strnca|secmp(aL|
|000023e0| 69 6e 65 2c 20 22 58 2d | 53 74 61 74 75 73 22 2c |ine, "X-|Status",|
|000023f0| 20 38 29 20 3d 3d 20 30 | 29 0a 09 20 20 20 20 7b | 8) == 0|).. {|
|00002400| 0a 09 20 20 20 20 20 20 | 5b 50 61 72 73 65 72 20 |.. |[Parser |
|00002410| 70 61 72 73 65 58 53 74 | 61 74 75 73 3a 20 5b 73 |parseXSt|atus: [s|
|00002420| 65 6c 66 20 75 6e 66 6f | 6c 64 4c 69 6e 65 73 53 |elf unfo|ldLinesS|
|00002430| 74 61 72 74 69 6e 67 57 | 69 74 68 3a 20 61 4c 69 |tartingW|ith: aLi|
|00002440| 6e 65 5d 0a 09 20 20 20 | 20 20 20 09 20 20 20 20 |ne].. | . |
|00002450| 20 20 69 6e 4d 65 73 73 | 61 67 65 3a 20 61 4c 6f | inMess|age: aLo|
|00002460| 63 61 6c 4d 65 73 73 61 | 67 65 5d 3b 0a 09 20 20 |calMessa|ge];.. |
|00002470| 20 20 7d 0a 09 20 20 65 | 6c 73 65 0a 09 20 20 20 | }.. e|lse.. |
|00002480| 20 7b 0a 09 20 20 20 20 | 20 20 5b 50 61 72 73 65 | {.. | [Parse|
|00002490| 72 20 70 61 72 73 65 55 | 6e 6b 6e 6f 77 6e 48 65 |r parseU|nknownHe|
|000024a0| 61 64 65 72 3a 20 5b 73 | 65 6c 66 20 75 6e 66 6f |ader: [s|elf unfo|
|000024b0| 6c 64 4c 69 6e 65 73 53 | 74 61 72 74 69 6e 67 57 |ldLinesS|tartingW|
|000024c0| 69 74 68 3a 20 61 4c 69 | 6e 65 5d 0a 09 20 20 20 |ith: aLi|ne].. |
|000024d0| 20 20 20 09 20 20 20 20 | 20 20 69 6e 4d 65 73 73 | . | inMess|
|000024e0| 61 67 65 3a 20 61 4c 6f | 63 61 6c 4d 65 73 73 61 |age: aLo|calMessa|
|000024f0| 67 65 5d 3b 0a 09 20 20 | 20 20 7d 0a 09 20 20 62 |ge];.. | }.. b|
|00002500| 72 65 61 6b 3b 0a 0a 09 | 63 61 73 65 20 27 5c 6e |reak;...|case '\n|
|00002510| 27 3a 0a 09 20 20 0a 09 | 20 20 5b 61 4c 6f 63 61 |':.. ..| [aLoca|
|00002520| 6c 4d 65 73 73 61 67 65 | 20 73 65 74 46 69 6c 65 |lMessage| setFile|
|00002530| 50 6f 73 69 74 69 6f 6e | 3a 20 62 65 67 69 6e 5d |Position|: begin]|
|00002540| 3b 0a 09 20 20 5b 61 4c | 6f 63 61 6c 4d 65 73 73 |;.. [aL|ocalMess|
|00002550| 61 67 65 20 73 65 74 42 | 6f 64 79 46 69 6c 65 50 |age setB|odyFileP|
|00002560| 6f 73 69 74 69 6f 6e 3a | 20 66 74 65 6c 6c 28 73 |osition:| ftell(s|
|00002570| 74 72 65 61 6d 29 5d 3b | 0a 0a 09 20 20 2f 2f 20 |tream)];|... // |
|00002580| 57 65 20 6d 75 73 74 20 | 73 65 74 20 74 68 69 73 |We must |set this|
|00002590| 20 69 6e 20 63 61 73 65 | 20 74 68 65 20 6c 61 73 | in case| the las|
|000025a0| 74 20 6d 65 73 73 61 67 | 65 20 6f 66 20 6f 75 72 |t messag|e of our|
|000025b0| 20 6d 62 6f 78 20 69 73 | 0a 09 20 20 2f 2f 20 61 | mbox is|.. // a|
|000025c0| 6e 20 22 65 6d 70 74 79 | 20 6d 65 73 73 61 67 65 |n "empty| message|
|000025d0| 22 2c 20 69 2e 65 2c 20 | 61 20 6d 65 73 73 61 67 |", i.e, |a messag|
|000025e0| 65 20 77 69 74 68 20 61 | 6c 6c 20 74 68 65 20 68 |e with a|ll the h|
|000025f0| 65 61 64 65 72 73 20 62 | 75 74 0a 09 20 20 2f 2f |eaders b|ut.. //|
|00002600| 20 77 69 74 68 20 61 6e | 20 65 6d 70 74 79 20 63 | with an| empty c|
|00002610| 6f 6e 74 65 6e 74 2e 0a | 09 20 20 65 6e 64 20 3d |ontent..|. end =|
|00002620| 20 66 74 65 6c 6c 28 73 | 74 72 65 61 6d 29 3b 0a | ftell(s|tream);.|
|00002630| 0a 09 20 20 77 68 69 6c | 65 20 28 66 67 65 74 73 |.. whil|e (fgets|
|00002640| 28 61 4c 69 6e 65 2c 20 | 31 30 32 34 2c 20 73 74 |(aLine, |1024, st|
|00002650| 72 65 61 6d 29 20 21 3d | 20 4e 55 4c 4c 29 0a 20 |ream) !=| NULL). |
|00002660| 20 20 20 20 20 20 20 20 | 20 20 20 7b 0a 20 20 20 | | {. |
|00002670| 20 20 20 20 20 20 20 20 | 20 20 20 69 66 20 28 73 | | if (s|
|00002680| 74 72 6e 63 6d 70 28 61 | 4c 69 6e 65 2c 20 22 46 |trncmp(a|Line, "F|
|00002690| 72 6f 6d 20 22 2c 20 35 | 29 20 3d 3d 20 30 29 20 |rom ", 5|) == 0) |
|000026a0| 62 72 65 61 6b 3b 0a 20 | 20 20 20 20 20 20 20 20 |break;. | |
|000026b0| 20 20 20 20 20 65 6c 73 | 65 20 65 6e 64 20 3d 20 | els|e end = |
|000026c0| 66 74 65 6c 6c 28 73 74 | 72 65 61 6d 29 3b 0a 20 |ftell(st|ream);. |
|000026d0| 20 20 20 20 20 20 20 20 | 20 20 20 7d 0a 0a 09 20 | | }... |
|000026e0| 20 66 73 65 65 6b 28 73 | 74 72 65 61 6d 2c 20 65 | fseek(s|tream, e|
|000026f0| 6e 64 2c 20 53 45 45 4b | 5f 53 45 54 29 3b 0a 20 |nd, SEEK|_SET);. |
|00002700| 20 20 20 20 20 20 20 20 | 20 73 69 7a 65 20 3d 20 | | size = |
|00002710| 65 6e 64 20 2d 20 62 65 | 67 69 6e 3b 0a 0a 09 20 |end - be|gin;... |
|00002720| 20 2f 2f 20 57 65 20 69 | 6e 63 72 65 6d 65 6e 74 | // We i|ncrement|
|00002730| 20 6f 75 72 20 69 6e 64 | 65 78 0a 09 20 20 69 6e | our ind|ex.. in|
|00002740| 64 65 78 20 3d 20 69 6e | 64 65 78 20 2b 20 31 3b |dex = in|dex + 1;|
|00002750| 0a 0a 09 20 20 2f 2f 20 | 57 65 20 73 65 74 20 74 |... // |We set t|
|00002760| 68 65 20 70 72 6f 70 65 | 72 74 69 65 73 20 6f 66 |he prope|rties of|
|00002770| 20 6f 75 72 20 6d 65 73 | 73 61 67 65 20 6f 62 6a | our mes|sage obj|
|00002780| 65 63 74 20 61 6e 64 20 | 77 65 20 61 64 64 20 69 |ect and |we add i|
|00002790| 74 20 74 6f 20 6f 75 72 | 20 66 6f 6c 64 65 72 2e |t to our| folder.|
|000027a0| 0a 20 20 20 20 20 20 20 | 20 20 20 5b 61 4c 6f 63 |. | [aLoc|
|000027b0| 61 6c 4d 65 73 73 61 67 | 65 20 73 65 74 53 69 7a |alMessag|e setSiz|
|000027c0| 65 3a 20 73 69 7a 65 5d | 3b 0a 09 20 20 5b 61 4c |e: size]|;.. [aL|
|000027d0| 6f 63 61 6c 4d 65 73 73 | 61 67 65 20 73 65 74 4d |ocalMess|age setM|
|000027e0| 65 73 73 61 67 65 4e 75 | 6d 62 65 72 3a 20 69 6e |essageNu|mber: in|
|000027f0| 64 65 78 5d 3b 0a 09 20 | 20 5b 61 4c 6f 63 61 6c |dex];.. | [aLocal|
|00002800| 4d 65 73 73 61 67 65 20 | 73 65 74 46 6f 6c 64 65 |Message |setFolde|
|00002810| 72 3a 20 73 65 6c 66 5d | 3b 0a 09 20 20 5b 73 65 |r: self]|;.. [se|
|00002820| 6c 66 20 61 70 70 65 6e | 64 4d 65 73 73 61 67 65 |lf appen|dMessage|
|00002830| 3a 20 61 4c 6f 63 61 6c | 4d 65 73 73 61 67 65 5d |: aLocal|Message]|
|00002840| 3b 0a 0a 09 20 20 2f 2f | 20 57 65 20 61 64 64 20 |;... //| We add |
|00002850| 74 6f 20 6f 75 72 20 63 | 61 63 68 65 0a 09 20 20 |to our c|ache.. |
|00002860| 5b 5b 73 65 6c 66 20 6c | 6f 63 61 6c 46 6f 6c 64 |[[self l|ocalFold|
|00002870| 65 72 43 61 63 68 65 4d | 61 6e 61 67 65 72 5d 20 |erCacheM|anager] |
|00002880| 61 64 64 4d 65 73 73 61 | 67 65 3a 20 61 4c 6f 63 |addMessa|ge: aLoc|
|00002890| 61 6c 4d 65 73 73 61 67 | 65 5d 3b 0a 0a 09 20 20 |alMessag|e];... |
|000028a0| 52 45 4c 45 41 53 45 28 | 61 4c 6f 63 61 6c 4d 65 |RELEASE(|aLocalMe|
|000028b0| 73 73 61 67 65 29 3b 0a | 0a 20 20 20 20 20 20 20 |ssage);.|. |
|000028c0| 20 20 20 62 65 67 69 6e | 20 3d 20 66 74 65 6c 6c | begin| = ftell|
|000028d0| 28 73 74 72 65 61 6d 29 | 3b 0a 20 20 0a 09 20 20 |(stream)|;. .. |
|000028e0| 2f 2f 20 57 65 20 72 65 | 2d 69 6e 69 74 20 6f 75 |// We re|-init ou|
|000028f0| 72 20 6d 65 73 73 61 67 | 65 20 61 6e 64 20 6f 75 |r messag|e and ou|
|00002900| 72 20 6d 75 74 61 62 6c | 65 20 73 74 72 69 6e 67 |r mutabl|e string|
|00002910| 20 66 6f 72 20 74 68 65 | 20 6e 65 78 74 20 6d 65 | for the| next me|
|00002920| 73 73 61 67 65 20 77 65 | 27 72 65 20 67 6f 6e 6e |ssage we|'re gonn|
|00002930| 61 20 72 65 61 64 0a 09 | 20 20 61 4c 6f 63 61 6c |a read..| aLocal|
|00002940| 4d 65 73 73 61 67 65 20 | 3d 20 5b 5b 4c 6f 63 61 |Message |= [[Loca|
|00002950| 6c 4d 65 73 73 61 67 65 | 20 61 6c 6c 6f 63 5d 20 |lMessage| alloc] |
|00002960| 69 6e 69 74 5d 3b 0a 0a | 09 20 20 62 72 65 61 6b |init];..|. break|
|00002970| 3b 0a 09 20 20 0a 09 64 | 65 66 61 75 6c 74 3a 0a |;.. ..d|efault:.|
|00002980| 09 20 20 5b 50 61 72 73 | 65 72 20 70 61 72 73 65 |. [Pars|er parse|
|00002990| 55 6e 6b 6e 6f 77 6e 48 | 65 61 64 65 72 3a 20 5b |UnknownH|eader: [|
|000029a0| 73 65 6c 66 20 75 6e 66 | 6f 6c 64 4c 69 6e 65 73 |self unf|oldLines|
|000029b0| 53 74 61 72 74 69 6e 67 | 57 69 74 68 3a 20 61 4c |Starting|With: aL|
|000029c0| 69 6e 65 5d 0a 09 20 20 | 09 20 20 69 6e 4d 65 73 |ine].. |. inMes|
|000029d0| 73 61 67 65 3a 20 61 4c | 6f 63 61 6c 4d 65 73 73 |sage: aL|ocalMess|
|000029e0| 61 67 65 5d 3b 0a 09 7d | 0a 20 20 20 20 7d 20 20 |age];..}|. } |
|000029f0| 0a 0a 20 20 2f 2f 20 57 | 65 20 73 79 6e 63 20 6f |.. // W|e sync o|
|00002a00| 75 72 20 63 61 63 68 65 | 0a 20 20 5b 5b 73 65 6c |ur cache|. [[sel|
|00002a10| 66 20 6c 6f 63 61 6c 46 | 6f 6c 64 65 72 43 61 63 |f localF|olderCac|
|00002a20| 68 65 4d 61 6e 61 67 65 | 72 5d 20 73 79 6e 63 68 |heManage|r] synch|
|00002a30| 72 6f 6e 69 7a 65 5d 3b | 0a 0a 20 20 52 45 4c 45 |ronize];|.. RELE|
|00002a40| 41 53 45 28 61 4c 6f 63 | 61 6c 4d 65 73 73 61 67 |ASE(aLoc|alMessag|
|00002a50| 65 29 3b 0a 0a 20 20 52 | 45 4c 45 41 53 45 28 70 |e);.. R|ELEASE(p|
|00002a60| 6f 6f 6c 29 3b 0a 7d 0a | 0a 2f 2f 0a 2f 2f 20 54 |ool);.}.|.//.// T|
|00002a70| 68 69 73 20 6d 65 74 68 | 6f 64 20 69 73 20 75 73 |his meth|od is us|
|00002a80| 65 64 20 74 6f 20 75 6e | 66 6f 6c 64 20 74 68 65 |ed to un|fold the|
|00002a90| 20 6c 69 6e 65 73 20 74 | 68 61 74 20 68 61 76 65 | lines t|hat have|
|00002aa0| 20 62 65 65 6e 20 66 6f | 6c 64 65 64 0a 2f 2f 20 | been fo|lded.// |
|00002ab0| 62 79 20 73 74 61 72 74 | 69 6e 67 20 77 69 74 68 |by start|ing with|
|00002ac0| 20 74 68 65 20 66 69 72 | 73 74 20 6c 69 6e 65 2e | the fir|st line.|
|00002ad0| 0a 2f 2f 20 0a 2d 20 28 | 4e 53 44 61 74 61 20 2a |.// .- (|NSData *|
|00002ae0| 29 20 75 6e 66 6f 6c 64 | 4c 69 6e 65 73 53 74 61 |) unfold|LinesSta|
|00002af0| 72 74 69 6e 67 57 69 74 | 68 3a 28 63 68 61 72 20 |rtingWit|h:(char |
|00002b00| 2a 29 20 66 69 72 73 74 | 4c 69 6e 65 0a 7b 0a 20 |*) first|Line.{. |
|00002b10| 20 4e 53 4d 75 74 61 62 | 6c 65 44 61 74 61 20 2a | NSMutab|leData *|
|00002b20| 61 4d 75 74 61 62 6c 65 | 44 61 74 61 3b 0a 20 20 |aMutable|Data;. |
|00002b30| 4e 53 44 61 74 61 20 2a | 61 44 61 74 61 3b 0a 20 |NSData *|aData;. |
|00002b40| 20 63 68 61 72 20 61 4c | 69 6e 65 5b 31 30 32 34 | char aL|ine[1024|
|00002b50| 5d 2c 20 62 75 66 5b 31 | 30 32 34 5d 3b 0a 20 20 |], buf[1|024];. |
|00002b60| 6c 6f 6e 67 20 6d 61 72 | 6b 3b 0a 20 20 0a 20 20 |long mar|k;. . |
|00002b70| 2f 2f 20 57 65 20 69 6e | 69 74 69 61 6c 69 7a 65 |// We in|itialize|
|00002b80| 20 6f 75 72 20 62 75 66 | 66 65 72 73 0a 20 20 6d | our buf|fers. m|
|00002b90| 65 6d 73 65 74 28 61 4c | 69 6e 65 2c 20 30 2c 20 |emset(aL|ine, 0, |
|00002ba0| 31 30 32 34 29 3b 0a 20 | 20 6d 65 6d 73 65 74 28 |1024);. | memset(|
|00002bb0| 62 75 66 2c 20 30 2c 20 | 31 30 32 34 29 3b 0a 20 |buf, 0, |1024);. |
|00002bc0| 20 20 20 0a 20 20 6d 61 | 72 6b 20 3d 20 66 74 65 | . ma|rk = fte|
|00002bd0| 6c 6c 28 73 74 72 65 61 | 6d 29 3b 0a 20 20 66 67 |ll(strea|m);. fg|
|00002be0| 65 74 73 28 61 4c 69 6e | 65 2c 20 31 30 32 34 2c |ets(aLin|e, 1024,|
|00002bf0| 20 73 74 72 65 61 6d 29 | 3b 0a 0a 20 20 69 66 20 | stream)|;.. if |
|00002c00| 28 61 4c 69 6e 65 20 3d | 3d 20 4e 55 4c 4c 29 0a |(aLine =|= NULL).|
|00002c10| 20 20 20 20 7b 0a 20 20 | 20 20 20 20 72 65 74 75 | {. | retu|
|00002c20| 72 6e 20 5b 4e 53 44 61 | 74 61 20 64 61 74 61 57 |rn [NSDa|ta dataW|
|00002c30| 69 74 68 42 79 74 65 73 | 3a 20 66 69 72 73 74 4c |ithBytes|: firstL|
|00002c40| 69 6e 65 20 20 6c 65 6e | 67 74 68 3a 20 73 74 72 |ine len|gth: str|
|00002c50| 6c 65 6e 28 66 69 72 73 | 74 4c 69 6e 65 29 5d 3b |len(firs|tLine)];|
|00002c60| 0a 20 20 20 20 7d 0a 0a | 20 20 2f 2f 20 57 65 20 |. }..| // We |
|00002c70| 63 72 65 61 74 65 20 6f | 75 72 20 6d 75 74 61 62 |create o|ur mutab|
|00002c80| 6c 65 20 64 61 74 61 0a | 20 20 61 4d 75 74 61 62 |le data.| aMutab|
|00002c90| 6c 65 44 61 74 61 20 3d | 20 5b 5b 4e 53 4d 75 74 |leData =| [[NSMut|
|00002ca0| 61 62 6c 65 44 61 74 61 | 20 61 6c 6c 6f 63 5d 20 |ableData| alloc] |
|00002cb0| 69 6e 69 74 57 69 74 68 | 43 61 70 61 63 69 74 79 |initWith|Capacity|
|00002cc0| 3a 20 73 74 72 6c 65 6e | 28 66 69 72 73 74 4c 69 |: strlen|(firstLi|
|00002cd0| 6e 65 29 5d 3b 0a 0a 20 | 20 2f 2f 20 57 65 20 72 |ne)];.. | // We r|
|00002ce0| 65 6d 6f 76 65 20 74 68 | 65 20 74 72 61 69 6c 69 |emove th|e traili|
|00002cf0| 6e 67 20 5c 6e 20 61 6e | 64 20 77 65 20 61 70 70 |ng \n an|d we app|
|00002d00| 65 6e 64 20 6f 75 72 20 | 66 69 72 73 74 20 6c 69 |end our |first li|
|00002d10| 6e 65 20 74 6f 20 6f 75 | 72 20 6d 75 74 61 62 6c |ne to ou|r mutabl|
|00002d20| 65 20 64 61 74 61 0a 20 | 20 73 74 72 6e 63 70 79 |e data. | strncpy|
|00002d30| 28 62 75 66 2c 20 66 69 | 72 73 74 4c 69 6e 65 2c |(buf, fi|rstLine,|
|00002d40| 20 73 74 72 6c 65 6e 28 | 66 69 72 73 74 4c 69 6e | strlen(|firstLin|
|00002d50| 65 29 20 2d 20 31 29 3b | 0a 20 20 5b 61 4d 75 74 |e) - 1);|. [aMut|
|00002d60| 61 62 6c 65 44 61 74 61 | 20 61 70 70 65 6e 64 43 |ableData| appendC|
|00002d70| 46 6f 72 6d 61 74 3a 20 | 40 22 25 73 20 22 2c 20 |Format: |@"%s ", |
|00002d80| 62 75 66 5d 3b 0a 20 20 | 0a 20 20 2f 2f 20 57 65 |buf];. |. // We|
|00002d90| 20 6c 6f 6f 70 20 61 73 | 20 6c 6f 6e 67 20 61 73 | loop as| long as|
|00002da0| 20 77 65 20 68 61 76 65 | 20 61 20 73 70 61 63 65 | we have| a space|
|00002db0| 20 6f 72 20 74 61 62 20 | 63 68 61 72 61 63 74 65 | or tab |characte|
|00002dc0| 72 20 61 73 20 74 68 65 | 20 66 69 72 73 74 20 63 |r as the| first c|
|00002dd0| 68 61 72 61 63 74 65 72 | 20 0a 20 20 2f 2f 20 6f |haracter| . // o|
|00002de0| 66 20 74 68 65 20 6c 69 | 6e 65 20 74 68 61 74 20 |f the li|ne that |
|00002df0| 77 65 20 6a 75 73 74 20 | 72 65 61 64 0a 20 20 77 |we just |read. w|
|00002e00| 68 69 6c 65 20 28 20 61 | 4c 69 6e 65 5b 30 5d 20 |hile ( a|Line[0] |
|00002e10| 3d 3d 20 39 20 7c 7c 20 | 61 4c 69 6e 65 5b 30 5d |== 9 || |aLine[0]|
|00002e20| 20 3d 3d 20 33 32 20 29 | 0a 20 20 20 20 7b 0a 20 | == 32 )|. {. |
|00002e30| 20 20 20 20 20 63 68 61 | 72 20 2a 70 74 72 3b 0a | cha|r *ptr;.|
|00002e40| 0a 20 20 20 20 20 20 2f | 2f 20 57 65 20 73 6b 69 |. /|/ We ski|
|00002e50| 70 20 74 68 65 20 66 69 | 72 73 74 20 63 68 61 72 |p the fi|rst char|
|00002e60| 0a 20 20 20 20 20 20 70 | 74 72 20 3d 20 61 4c 69 |. p|tr = aLi|
|00002e70| 6e 65 3b 0a 20 20 20 20 | 20 20 70 74 72 2b 2b 3b |ne;. | ptr++;|
|00002e80| 0a 20 20 20 20 20 20 0a | 20 20 20 20 20 20 2f 2f |. .| //|
|00002e90| 20 57 65 20 69 6e 69 74 | 20 6f 75 72 20 62 75 66 | We init| our buf|
|00002ea0| 66 65 72 20 61 6e 64 20 | 77 65 20 63 6f 70 79 20 |fer and |we copy |
|00002eb0| 74 68 65 20 64 61 74 61 | 20 69 6e 74 6f 20 69 74 |the data| into it|
|00002ec0| 20 62 79 20 74 72 69 6d | 6d 69 6e 67 20 74 68 65 | by trim|ming the|
|00002ed0| 20 74 72 61 69 6c 69 6e | 67 20 5c 6e 0a 20 20 20 | trailin|g \n. |
|00002ee0| 20 20 20 6d 65 6d 73 65 | 74 28 62 75 66 2c 20 30 | memse|t(buf, 0|
|00002ef0| 2c 20 31 30 32 34 29 3b | 0a 20 20 20 20 20 20 73 |, 1024);|. s|
|00002f00| 74 72 6e 63 70 79 28 62 | 75 66 2c 20 70 74 72 2c |trncpy(b|uf, ptr,|
|00002f10| 20 73 74 72 6c 65 6e 28 | 70 74 72 29 20 2d 20 31 | strlen(|ptr) - 1|
|00002f20| 29 3b 0a 20 20 20 20 20 | 20 5b 61 4d 75 74 61 62 |);. | [aMutab|
|00002f30| 6c 65 44 61 74 61 20 61 | 70 70 65 6e 64 43 46 6f |leData a|ppendCFo|
|00002f40| 72 6d 61 74 3a 20 40 22 | 25 73 20 22 2c 20 62 75 |rmat: @"|%s ", bu|
|00002f50| 66 5d 3b 0a 0a 20 20 20 | 20 20 20 2f 2f 20 57 65 |f];.. | // We|
|00002f60| 20 73 65 74 20 6f 75 72 | 20 6d 61 72 6b 20 61 6e | set our| mark an|
|00002f70| 64 20 67 65 74 20 74 68 | 65 20 6e 65 78 74 20 66 |d get th|e next f|
|00002f80| 6f 6c 64 65 64 20 6c 69 | 6e 65 20 28 69 66 20 74 |olded li|ne (if t|
|00002f90| 68 65 72 65 27 73 20 6f | 6e 65 29 0a 20 20 20 20 |here's o|ne). |
|00002fa0| 20 20 6d 61 72 6b 20 3d | 20 66 74 65 6c 6c 28 73 | mark =| ftell(s|
|00002fb0| 74 72 65 61 6d 29 3b 0a | 20 20 20 20 20 20 6d 65 |tream);.| me|
|00002fc0| 6d 73 65 74 28 61 4c 69 | 6e 65 2c 20 30 2c 20 31 |mset(aLi|ne, 0, 1|
|00002fd0| 30 32 34 29 3b 0a 20 20 | 20 20 20 20 66 67 65 74 |024);. | fget|
|00002fe0| 73 28 61 4c 69 6e 65 2c | 20 31 30 32 34 2c 20 73 |s(aLine,| 1024, s|
|00002ff0| 74 72 65 61 6d 29 3b 0a | 20 20 20 20 20 20 0a 20 |tream);.| . |
|00003000| 20 20 20 20 20 69 66 20 | 28 61 4c 69 6e 65 20 3d | if |(aLine =|
|00003010| 3d 20 4e 55 4c 4c 29 0a | 20 20 20 20 20 20 20 20 |= NULL).| |
|00003020| 7b 0a 09 20 20 52 45 4c | 45 41 53 45 28 61 4d 75 |{.. REL|EASE(aMu|
|00003030| 74 61 62 6c 65 44 61 74 | 61 29 3b 0a 20 20 20 20 |tableDat|a);. |
|00003040| 20 20 20 20 20 20 72 65 | 74 75 72 6e 20 6e 69 6c | re|turn nil|
|00003050| 3b 0a 20 20 20 20 20 20 | 20 20 7d 0a 20 20 20 20 |;. | }. |
|00003060| 7d 0a 0a 20 20 2f 2f 20 | 57 65 20 72 65 73 65 74 |}.. // |We reset|
|00003070| 20 6f 75 72 20 66 69 6c | 65 20 70 6f 69 6e 74 65 | our fil|e pointe|
|00003080| 72 20 70 6f 73 69 74 69 | 6f 6e 20 61 6e 64 20 77 |r positi|on and w|
|00003090| 65 20 66 72 65 65 20 6f | 75 72 20 43 20 62 75 66 |e free o|ur C buf|
|000030a0| 66 65 72 73 2e 0a 20 20 | 66 73 65 65 6b 28 73 74 |fers.. |fseek(st|
|000030b0| 72 65 61 6d 2c 20 6d 61 | 72 6b 2c 20 53 45 45 4b |ream, ma|rk, SEEK|
|000030c0| 5f 53 45 54 29 3b 0a 20 | 20 0a 20 20 2f 2f 20 57 |_SET);. | . // W|
|000030d0| 65 20 74 72 69 6d 20 6f | 75 72 20 6c 61 73 74 20 |e trim o|ur last |
|000030e0| 22 20 22 20 74 68 61 74 | 20 77 65 20 61 64 64 65 |" " that| we adde|
|000030f0| 64 20 74 6f 20 6f 75 72 | 20 64 61 74 61 0a 20 20 |d to our| data. |
|00003100| 61 44 61 74 61 20 3d 20 | 5b 61 4d 75 74 61 62 6c |aData = |[aMutabl|
|00003110| 65 44 61 74 61 20 73 75 | 62 64 61 74 61 54 6f 49 |eData su|bdataToI|
|00003120| 6e 64 65 78 3a 20 5b 61 | 4d 75 74 61 62 6c 65 44 |ndex: [a|MutableD|
|00003130| 61 74 61 20 6c 65 6e 67 | 74 68 5d 20 2d 20 31 5d |ata leng|th] - 1]|
|00003140| 3b 0a 20 20 0a 20 20 52 | 45 4c 45 41 53 45 28 61 |;. . R|ELEASE(a|
|00003150| 4d 75 74 61 62 6c 65 44 | 61 74 61 29 3b 0a 0a 20 |MutableD|ata);.. |
|00003160| 20 72 65 74 75 72 6e 20 | 61 44 61 74 61 3b 0a 7d | return |aData;.}|
|00003170| 0a 0a 0a 2f 2f 0a 2f 2f | 20 54 68 69 73 20 6d 65 |...//.//| This me|
|00003180| 74 68 6f 64 20 69 73 20 | 75 73 65 64 20 74 6f 20 |thod is |used to |
|00003190| 63 6c 6f 73 65 20 74 68 | 65 20 63 75 72 72 65 6e |close th|e curren|
|000031a0| 74 20 66 6f 6c 64 65 72 | 2e 0a 2f 2f 20 49 74 20 |t folder|..// It |
|000031b0| 63 72 65 61 74 65 73 20 | 61 20 74 65 6d 70 6f 72 |creates |a tempor|
|000031c0| 61 72 79 20 66 69 6c 65 | 20 77 68 65 72 65 20 74 |ary file| where t|
|000031d0| 68 65 20 66 6f 6c 64 65 | 72 20 69 73 20 77 72 69 |he folde|r is wri|
|000031e0| 74 74 65 6e 20 74 6f 20 | 61 6e 64 0a 2f 2f 20 69 |tten to |and.// i|
|000031f0| 74 20 72 65 70 6c 61 63 | 65 73 20 74 68 65 20 63 |t replac|es the c|
|00003200| 75 72 72 65 6e 74 20 66 | 6f 6c 64 65 72 20 66 69 |urrent f|older fi|
|00003210| 6c 65 20 62 79 20 74 68 | 69 73 20 6f 6e 65 20 6f |le by th|is one o|
|00003220| 6e 63 65 20 65 76 65 72 | 79 74 68 69 6e 67 20 69 |nce ever|ything i|
|00003230| 73 0a 2f 2f 20 61 6c 72 | 69 67 68 74 2e 0a 2f 2f |s.// alr|ight..//|
|00003240| 0a 2d 20 28 76 6f 69 64 | 29 20 63 6c 6f 73 65 0a |.- (void|) close.|
|00003250| 7b 0a 20 20 4c 6f 63 61 | 6c 53 74 6f 72 65 20 2a |{. Loca|lStore *|
|00003260| 61 4c 6f 63 61 6c 53 74 | 6f 72 65 20 3d 20 6e 69 |aLocalSt|ore = ni|
|00003270| 6c 3b 0a 0a 20 20 2f 2f | 20 57 65 20 66 69 72 73 |l;.. //| We firs|
|00003280| 74 20 6f 62 74 61 69 6e | 20 61 20 72 65 66 65 72 |t obtain| a refer|
|00003290| 65 6e 63 65 20 74 6f 20 | 6f 75 72 20 6c 6f 63 61 |ence to |our loca|
|000032a0| 6c 20 73 74 6f 72 65 0a | 20 20 61 4c 6f 63 61 6c |l store.| aLocal|
|000032b0| 53 74 6f 72 65 20 3d 20 | 28 4c 6f 63 61 6c 53 74 |Store = |(LocalSt|
|000032c0| 6f 72 65 20 2a 29 5b 73 | 65 6c 66 20 73 74 6f 72 |ore *)[s|elf stor|
|000032d0| 65 5d 3b 0a 0a 20 20 2f | 2f 20 57 65 20 63 6c 6f |e];.. /|/ We clo|
|000032e0| 73 65 20 74 68 65 20 63 | 75 72 72 65 6e 74 20 66 |se the c|urrent f|
|000032f0| 6f 6c 64 65 72 0a 20 20 | 2f 2f 4e 53 44 65 62 75 |older. |//NSDebu|
|00003300| 67 4c 6f 67 28 40 22 43 | 6c 6f 73 69 6e 67 20 25 |gLog(@"C|losing %|
|00003310| 40 2e 2e 2e 22 2c 20 5b | 73 65 6c 66 20 6e 61 6d |@...", [|self nam|
|00003320| 65 5d 29 3b 0a 20 20 66 | 63 6c 6f 73 65 28 5b 73 |e]);. f|close([s|
|00003330| 65 6c 66 20 73 74 72 65 | 61 6d 5d 29 3b 0a 20 20 |elf stre|am]);. |
|00003340| 66 6c 6f 63 6b 28 5b 73 | 65 6c 66 20 66 64 5d 2c |flock([s|elf fd],|
|00003350| 20 4c 4f 43 4b 5f 55 4e | 29 3b 0a 20 20 63 6c 6f | LOCK_UN|);. clo|
|00003360| 73 65 28 5b 73 65 6c 66 | 20 66 64 5d 29 3b 0a 0a |se([self| fd]);..|
|00003370| 20 20 2f 2f 20 57 65 20 | 73 79 6e 63 68 6f 72 69 | // We |synchori|
|00003380| 7a 65 20 6f 75 72 20 63 | 61 63 68 65 20 6f 6e 65 |ze our c|ache one|
|00003390| 20 6c 61 73 74 20 74 69 | 6d 65 0a 20 20 5b 5b 73 | last ti|me. [[s|
|000033a0| 65 6c 66 20 6c 6f 63 61 | 6c 46 6f 6c 64 65 72 43 |elf loca|lFolderC|
|000033b0| 61 63 68 65 4d 61 6e 61 | 67 65 72 5d 20 73 79 6e |acheMana|ger] syn|
|000033c0| 63 68 72 6f 6e 69 7a 65 | 5d 3b 0a 0a 20 20 2f 2f |chronize|];.. //|
|000033d0| 20 57 65 20 72 65 6d 6f | 76 65 20 6f 75 72 20 63 | We remo|ve our c|
|000033e0| 75 72 72 65 6e 74 20 66 | 6f 6c 64 65 72 20 66 72 |urrent f|older fr|
|000033f0| 6f 6d 20 74 68 65 20 6c | 69 73 74 20 6f 66 20 6f |om the l|ist of o|
|00003400| 70 65 6e 65 64 20 66 6f | 6c 64 65 72 73 20 69 6e |pened fo|lders in|
|00003410| 20 74 68 65 20 73 74 6f | 72 65 0a 20 20 5b 61 4c | the sto|re. [aL|
|00003420| 6f 63 61 6c 53 74 6f 72 | 65 20 72 65 6d 6f 76 65 |ocalStor|e remove|
|00003430| 46 6f 6c 64 65 72 46 72 | 6f 6d 4f 70 65 6e 65 64 |FolderFr|omOpened|
|00003440| 46 6f 6c 64 65 72 73 3a | 20 73 65 6c 66 5d 3b 0a |Folders:| self];.|
|00003450| 7d 0a 0a 0a 2f 2f 0a 2f | 2f 20 54 68 69 73 20 6d |}...//./|/ This m|
|00003460| 65 74 68 6f 64 20 70 65 | 72 6d 61 6e 65 6e 74 6c |ethod pe|rmanentl|
|00003470| 79 20 72 65 6d 6f 76 65 | 73 20 6d 65 73 73 61 67 |y remove|s messag|
|00003480| 65 73 20 74 68 61 74 20 | 68 61 76 65 20 74 68 65 |es that |have the|
|00003490| 20 66 6c 61 67 20 27 44 | 45 4c 45 54 45 44 27 0a | flag 'D|ELETED'.|
|000034a0| 2f 2f 20 4f 52 20 27 54 | 52 41 4e 53 46 45 52 52 |// OR 'T|RANSFERR|
|000034b0| 45 44 27 0a 2f 2f 0a 2f | 2f 20 54 68 69 73 20 6d |ED'.//./|/ This m|
|000034c0| 65 74 68 6f 64 20 72 65 | 74 75 72 6e 73 20 61 6c |ethod re|turns al|
|000034d0| 6c 20 6d 65 73 73 61 67 | 65 73 20 74 68 61 74 20 |l messag|es that |
|000034e0| 68 61 76 65 20 74 68 65 | 20 66 6c 61 67 20 27 44 |have the| flag 'D|
|000034f0| 45 4c 45 54 45 44 27 0a | 2f 2f 20 41 6c 6c 20 74 |ELETED'.|// All t|
|00003500| 68 65 20 72 65 74 75 72 | 6e 65 64 20 6d 65 73 73 |he retur|ned mess|
|00003510| 61 67 65 20 41 52 45 20 | 49 4e 20 52 41 57 20 53 |age ARE |IN RAW S|
|00003520| 4f 55 52 43 45 2e 0a 2f | 2f 0a 2d 20 28 4e 53 41 |OURCE../|/.- (NSA|
|00003530| 72 72 61 79 20 2a 29 20 | 65 78 70 75 6e 67 65 3a |rray *) |expunge:|
|00003540| 20 28 42 4f 4f 4c 29 20 | 72 65 74 75 72 6e 44 65 | (BOOL) |returnDe|
|00003550| 6c 65 74 65 64 4d 65 73 | 73 61 67 65 73 20 0a 7b |letedMes|sages .{|
|00003560| 0a 20 20 4e 53 4d 75 74 | 61 62 6c 65 41 72 72 61 |. NSMut|ableArra|
|00003570| 79 20 2a 61 4d 75 74 61 | 62 6c 65 41 72 72 61 79 |y *aMuta|bleArray|
|00003580| 3b 0a 20 20 0a 20 20 46 | 49 4c 45 20 2a 74 68 65 |;. . F|ILE *the|
|00003590| 4f 75 74 70 75 74 53 74 | 72 65 61 6d 3b 0a 20 20 |OutputSt|ream;. |
|000035a0| 4c 6f 63 61 6c 53 74 6f | 72 65 20 2a 61 4c 6f 63 |LocalSto|re *aLoc|
|000035b0| 61 6c 53 74 6f 72 65 3b | 0a 0a 20 20 4c 6f 63 61 |alStore;|.. Loca|
|000035c0| 6c 4d 65 73 73 61 67 65 | 20 2a 61 4d 65 73 73 61 |lMessage| *aMessa|
|000035d0| 67 65 3b 0a 20 20 46 6c | 61 67 73 20 2a 74 68 65 |ge;. Fl|ags *the|
|000035e0| 46 6c 61 67 73 3b 0a 0a | 20 20 42 4f 4f 4c 20 77 |Flags;..| BOOL w|
|000035f0| 72 69 74 65 57 61 73 53 | 75 63 63 65 73 73 66 75 |riteWasS|uccessfu|
|00003600| 6c 3b 0a 20 20 4e 53 53 | 74 72 69 6e 67 20 2a 70 |l;. NSS|tring *p|
|00003610| 61 74 68 54 6f 4d 61 69 | 6c 62 6f 78 3b 0a 0a 20 |athToMai|lbox;.. |
|00003620| 20 69 6e 74 20 69 2c 20 | 6d 65 73 73 61 67 65 4e | int i, |messageN|
|00003630| 75 6d 62 65 72 3b 0a 20 | 20 63 68 61 72 20 61 4c |umber;. | char aL|
|00003640| 69 6e 65 5b 31 30 32 34 | 5d 3b 0a 20 20 0a 20 20 |ine[1024|];. . |
|00003650| 2f 2f 20 57 65 20 66 69 | 72 73 74 20 6f 62 74 61 |// We fi|rst obta|
|00003660| 69 6e 20 61 20 72 65 66 | 65 72 65 6e 63 65 20 74 |in a ref|erence t|
|00003670| 6f 20 6f 75 72 20 6c 6f | 63 61 6c 20 73 74 6f 72 |o our lo|cal stor|
|00003680| 65 0a 20 20 61 4c 6f 63 | 61 6c 53 74 6f 72 65 20 |e. aLoc|alStore |
|00003690| 3d 20 28 4c 6f 63 61 6c | 53 74 6f 72 65 20 2a 29 |= (Local|Store *)|
|000036a0| 5b 73 65 6c 66 20 73 74 | 6f 72 65 5d 3b 0a 0a 20 |[self st|ore];.. |
|000036b0| 20 70 61 74 68 54 6f 4d | 61 69 6c 62 6f 78 20 3d | pathToM|ailbox =|
|000036c0| 20 5b 4e 53 53 74 72 69 | 6e 67 20 73 74 72 69 6e | [NSStri|ng strin|
|000036d0| 67 57 69 74 68 46 6f 72 | 6d 61 74 3a 20 40 22 25 |gWithFor|mat: @"%|
|000036e0| 40 2f 25 40 22 2c 20 5b | 61 4c 6f 63 61 6c 53 74 |@/%@", [|aLocalSt|
|000036f0| 6f 72 65 20 70 61 74 68 | 5d 2c 0a 09 09 09 20 20 |ore path|],.... |
|00003700| 20 20 5b 73 65 6c 66 20 | 6e 61 6d 65 5d 5d 3b 0a | [self |name]];.|
|00003710| 20 20 0a 20 20 2f 2f 20 | 54 68 65 20 73 74 72 65 | . // |The stre|
|00003720| 61 6d 20 69 73 20 75 73 | 65 64 20 74 6f 20 73 74 |am is us|ed to st|
|00003730| 6f 72 65 20 74 65 6d 70 | 6f 72 61 72 79 20 6f 75 |ore temp|orary ou|
|00003740| 72 20 27 6e 65 77 20 6c | 6f 63 61 6c 20 66 6f 6c |r 'new l|ocal fol|
|00003750| 64 65 72 27 0a 20 20 74 | 68 65 4f 75 74 70 75 74 |der'. t|heOutput|
|00003760| 53 74 72 65 61 6d 20 3d | 20 66 6f 70 65 6e 28 5b |Stream =| fopen([|
|00003770| 5b 4e 53 53 74 72 69 6e | 67 20 73 74 72 69 6e 67 |[NSStrin|g string|
|00003780| 57 69 74 68 46 6f 72 6d | 61 74 3a 40 22 25 40 2e |WithForm|at:@"%@.|
|00003790| 74 6d 70 22 2c 20 70 61 | 74 68 54 6f 4d 61 69 6c |tmp", pa|thToMail|
|000037a0| 62 6f 78 5d 0a 09 09 09 | 20 20 20 20 63 53 74 72 |box]....| cStr|
|000037b0| 69 6e 67 5d 2c 20 22 61 | 22 29 3b 0a 20 20 0a 20 |ing], "a|");. . |
|000037c0| 20 2f 2f 20 57 65 20 61 | 73 73 75 6d 65 20 74 68 | // We a|ssume th|
|000037d0| 61 74 20 6f 75 72 20 77 | 72 69 74 65 20 6f 70 65 |at our w|rite ope|
|000037e0| 72 61 74 69 6f 6e 20 77 | 61 73 20 73 75 63 63 65 |ration w|as succe|
|000037f0| 73 73 66 75 6c 20 61 6e | 64 20 77 65 20 69 6e 69 |ssful an|d we ini|
|00003800| 74 69 61 6c 69 7a 65 20 | 6f 75 72 20 6d 65 73 73 |tialize |our mess|
|00003810| 61 67 65 4e 75 6d 62 65 | 72 20 74 6f 20 31 0a 20 |ageNumbe|r to 1. |
|00003820| 20 77 72 69 74 65 57 61 | 73 53 75 63 63 65 73 73 | writeWa|sSuccess|
|00003830| 66 75 6c 20 3d 20 59 45 | 53 3b 0a 20 20 6d 65 73 |ful = YE|S;. mes|
|00003840| 73 61 67 65 4e 75 6d 62 | 65 72 20 3d 20 31 3b 0a |sageNumb|er = 1;.|
|00003850| 20 20 0a 20 20 2f 2f 20 | 57 65 20 76 65 72 69 66 | . // |We verif|
|00003860| 79 20 69 74 20 74 68 65 | 20 63 72 65 61 74 69 6f |y it the| creatio|
|00003870| 6e 20 66 61 69 6c 65 64 | 0a 20 20 69 66 20 28 20 |n failed|. if ( |
|00003880| 21 74 68 65 4f 75 74 70 | 75 74 53 74 72 65 61 6d |!theOutp|utStream|
|00003890| 20 29 0a 20 20 20 20 7b | 0a 20 20 20 20 20 20 4e | ). {|. N|
|000038a0| 53 44 65 62 75 67 4c 6f | 67 28 40 22 55 6e 61 62 |SDebugLo|g(@"Unab|
|000038b0| 6c 65 20 74 6f 20 63 72 | 65 61 74 65 20 74 68 65 |le to cr|eate the|
|000038c0| 20 74 65 6d 70 6f 72 61 | 72 79 20 66 6f 6c 64 65 | tempora|ry folde|
|000038d0| 72 20 69 6e 20 4c 6f 63 | 61 6c 46 6f 6c 64 65 72 |r in Loc|alFolder|
|000038e0| 3a 20 2d 65 78 70 75 6e | 67 65 2e 22 29 3b 0a 20 |: -expun|ge.");. |
|000038f0| 20 20 20 20 20 72 65 74 | 75 72 6e 20 5b 4e 53 41 | ret|urn [NSA|
|00003900| 72 72 61 79 20 61 72 72 | 61 79 5d 3b 0a 20 20 20 |rray arr|ay];. |
|00003910| 20 7d 0a 20 20 0a 20 20 | 61 4d 75 74 61 62 6c 65 | }. . |aMutable|
|00003920| 41 72 72 61 79 20 3d 20 | 5b 5b 4e 53 4d 75 74 61 |Array = |[[NSMuta|
|00003930| 62 6c 65 41 72 72 61 79 | 20 61 6c 6c 6f 63 5d 20 |bleArray| alloc] |
|00003940| 69 6e 69 74 5d 3b 0a 0a | 20 20 66 6f 72 20 28 69 |init];..| for (i|
|00003950| 20 3d 20 30 3b 20 69 20 | 3c 20 5b 61 6c 6c 4d 65 | = 0; i |< [allMe|
|00003960| 73 73 61 67 65 73 20 63 | 6f 75 6e 74 5d 3b 20 69 |ssages c|ount]; i|
|00003970| 2b 2b 29 0a 20 20 20 20 | 7b 0a 20 20 20 20 20 20 |++). |{. |
|00003980| 61 4d 65 73 73 61 67 65 | 20 3d 20 5b 61 6c 6c 4d |aMessage| = [allM|
|00003990| 65 73 73 61 67 65 73 20 | 6f 62 6a 65 63 74 41 74 |essages |objectAt|
|000039a0| 49 6e 64 65 78 3a 20 69 | 5d 3b 0a 0a 20 20 20 20 |Index: i|];.. |
|000039b0| 20 20 74 68 65 46 6c 61 | 67 73 20 3d 20 5b 61 4d | theFla|gs = [aM|
|000039c0| 65 73 73 61 67 65 20 66 | 6c 61 67 73 5d 3b 0a 0a |essage f|lags];..|
|000039d0| 20 20 20 20 20 20 69 66 | 20 28 20 5b 74 68 65 46 | if| ( [theF|
|000039e0| 6c 61 67 73 20 63 6f 6e | 74 61 69 6e 3a 20 44 45 |lags con|tain: DE|
|000039f0| 4c 45 54 45 44 5d 20 29 | 0a 09 7b 0a 09 20 20 2f |LETED] )|..{.. /|
|00003a00| 2f 20 57 65 20 61 64 64 | 20 6f 75 72 20 6d 65 73 |/ We add| our mes|
|00003a10| 73 61 67 65 20 74 6f 20 | 6f 75 72 20 61 72 72 61 |sage to |our arra|
|00003a20| 79 20 6f 66 20 64 65 6c | 65 74 65 64 20 6d 65 73 |y of del|eted mes|
|00003a30| 73 61 67 65 73 2c 20 69 | 66 20 77 65 20 6e 65 65 |sages, i|f we nee|
|00003a40| 64 20 74 6f 2e 0a 09 20 | 20 69 66 20 28 20 72 65 |d to... | if ( re|
|00003a50| 74 75 72 6e 44 65 6c 65 | 74 65 64 4d 65 73 73 61 |turnDele|tedMessa|
|00003a60| 67 65 73 20 29 0a 09 20 | 20 20 20 7b 0a 09 20 20 |ges ).. | {.. |
|00003a70| 20 20 20 20 5b 61 4d 75 | 74 61 62 6c 65 41 72 72 | [aMu|tableArr|
|00003a80| 61 79 20 61 64 64 4f 62 | 6a 65 63 74 3a 20 5b 61 |ay addOb|ject: [a|
|00003a90| 4d 65 73 73 61 67 65 20 | 72 61 77 53 6f 75 72 63 |Message |rawSourc|
|00003aa0| 65 5d 5d 3b 0a 09 20 20 | 20 20 7d 0a 09 20 20 0a |e]];.. | }.. .|
|00003ab0| 09 20 20 5b 5b 73 65 6c | 66 20 6c 6f 63 61 6c 46 |. [[sel|f localF|
|00003ac0| 6f 6c 64 65 72 43 61 63 | 68 65 4d 61 6e 61 67 65 |olderCac|heManage|
|00003ad0| 72 5d 20 72 65 6d 6f 76 | 65 4d 65 73 73 61 67 65 |r] remov|eMessage|
|00003ae0| 3a 20 61 4d 65 73 73 61 | 67 65 5d 3b 0a 09 7d 0a |: aMessa|ge];..}.|
|00003af0| 20 20 20 20 20 20 65 6c | 73 65 20 69 66 20 28 20 | el|se if ( |
|00003b00| 5b 74 68 65 46 6c 61 67 | 73 20 63 6f 6e 74 61 69 |[theFlag|s contai|
|00003b10| 6e 3a 20 54 52 41 4e 53 | 46 45 52 52 45 44 5d 20 |n: TRANS|FERRED] |
|00003b20| 29 0a 09 7b 0a 09 20 20 | 2f 2f 20 57 65 20 64 6f |)..{.. |// We do|
|00003b30| 20 6e 6f 74 68 69 6e 67 | 20 66 6f 72 20 61 20 74 | nothing| for a t|
|00003b40| 72 61 6e 73 66 65 72 72 | 65 64 20 6d 65 73 73 61 |ransferr|ed messa|
|00003b50| 67 65 20 73 6f 20 69 74 | 27 6c 6c 20 6a 75 73 74 |ge so it|'ll just|
|00003b60| 20 67 65 74 0a 09 20 20 | 2f 2f 20 64 65 6c 65 74 | get.. |// delet|
|00003b70| 65 64 2e 0a 09 20 20 5b | 5b 73 65 6c 66 20 6c 6f |ed... [|[self lo|
|00003b80| 63 61 6c 46 6f 6c 64 65 | 72 43 61 63 68 65 4d 61 |calFolde|rCacheMa|
|00003b90| 6e 61 67 65 72 5d 20 72 | 65 6d 6f 76 65 4d 65 73 |nager] r|emoveMes|
|00003ba0| 73 61 67 65 3a 20 61 4d | 65 73 73 61 67 65 5d 3b |sage: aM|essage];|
|00003bb0| 0a 09 7d 0a 20 20 20 20 | 20 20 65 6c 73 65 0a 09 |..}. | else..|
|00003bc0| 7b 0a 09 20 20 69 6e 74 | 20 68 65 61 64 65 72 73 |{.. int| headers|
|00003bd0| 5f 6c 65 6e 67 74 68 3b | 0a 09 20 20 6c 6f 6e 67 |_length;|.. long|
|00003be0| 20 70 6f 73 69 74 69 6f | 6e 3b 20 0a 0a 09 20 20 | positio|n; ... |
|00003bf0| 2f 2f 20 57 65 20 67 65 | 74 20 6f 75 72 20 70 6f |// We ge|t our po|
|00003c00| 73 69 74 69 6f 6e 20 61 | 6e 64 20 68 65 61 64 65 |sition a|nd heade|
|00003c10| 72 73 5f 6c 65 6e 67 74 | 68 0a 09 20 20 70 6f 73 |rs_lengt|h.. pos|
|00003c20| 69 74 69 6f 6e 20 3d 20 | 66 74 65 6c 6c 28 74 68 |ition = |ftell(th|
|00003c30| 65 4f 75 74 70 75 74 53 | 74 72 65 61 6d 29 3b 0a |eOutputS|tream);.|
|00003c40| 09 20 20 68 65 61 64 65 | 72 73 5f 6c 65 6e 67 74 |. heade|rs_lengt|
|00003c50| 68 20 3d 20 28 5b 61 4d | 65 73 73 61 67 65 20 62 |h = ([aM|essage b|
|00003c60| 6f 64 79 46 69 6c 65 50 | 6f 73 69 74 69 6f 6e 5d |odyFileP|osition]|
|00003c70| 20 2d 20 5b 61 4d 65 73 | 73 61 67 65 20 66 69 6c | - [aMes|sage fil|
|00003c80| 65 50 6f 73 69 74 69 6f | 6e 5d 29 3b 20 0a 09 20 |ePositio|n]); .. |
|00003c90| 20 0a 09 20 20 2f 2f 20 | 57 65 20 73 65 65 6b 0a | .. // |We seek.|
|00003ca0| 09 20 20 66 73 65 65 6b | 28 5b 73 65 6c 66 20 73 |. fseek|([self s|
|00003cb0| 74 72 65 61 6d 5d 2c 20 | 5b 61 4d 65 73 73 61 67 |tream], |[aMessag|
|00003cc0| 65 20 66 69 6c 65 50 6f | 73 69 74 69 6f 6e 5d 2c |e filePo|sition],|
|00003cd0| 20 53 45 45 4b 5f 53 45 | 54 29 3b 0a 09 20 20 0a | SEEK_SE|T);.. .|
|00003ce0| 09 20 20 6d 65 6d 73 65 | 74 28 61 4c 69 6e 65 2c |. memse|t(aLine,|
|00003cf0| 20 30 2c 20 31 30 32 34 | 29 3b 0a 09 20 20 20 20 | 0, 1024|);.. |
|00003d00| 20 20 0a 09 20 20 77 68 | 69 6c 65 28 20 66 67 65 | .. wh|ile( fge|
|00003d10| 74 73 28 61 4c 69 6e 65 | 2c 20 31 30 32 34 2c 20 |ts(aLine|, 1024, |
|00003d20| 5b 73 65 6c 66 20 73 74 | 72 65 61 6d 5d 29 20 21 |[self st|ream]) !|
|00003d30| 3d 20 4e 55 4c 4c 20 26 | 26 20 0a 09 09 20 28 66 |= NULL &|& ... (f|
|00003d40| 74 65 6c 6c 28 5b 73 65 | 6c 66 20 73 74 72 65 61 |tell([se|lf strea|
|00003d50| 6d 5d 29 20 3c 20 28 5b | 61 4d 65 73 73 61 67 65 |m]) < ([|aMessage|
|00003d60| 20 66 69 6c 65 50 6f 73 | 69 74 69 6f 6e 5d 20 2b | filePos|ition] +|
|00003d70| 20 5b 61 4d 65 73 73 61 | 67 65 20 73 69 7a 65 5d | [aMessa|ge size]|
|00003d80| 29 29 20 29 0a 09 20 20 | 20 20 7b 0a 09 20 20 20 |)) ).. | {.. |
|00003d90| 20 20 20 2f 2f 20 57 65 | 20 77 72 69 74 65 20 6f | // We| write o|
|00003da0| 75 72 20 6c 69 6e 65 20 | 74 6f 20 6f 75 72 20 6e |ur line |to our n|
|00003db0| 65 77 20 73 74 72 65 61 | 6d 0a 09 20 20 20 20 20 |ew strea|m.. |
|00003dc0| 20 69 66 20 28 20 66 70 | 75 74 73 28 61 4c 69 6e | if ( fp|uts(aLin|
|00003dd0| 65 2c 20 74 68 65 4f 75 | 74 70 75 74 53 74 72 65 |e, theOu|tputStre|
|00003de0| 61 6d 29 20 3c 20 30 20 | 29 0a 09 09 7b 0a 09 09 |am) < 0 |)...{...|
|00003df0| 20 20 77 72 69 74 65 57 | 61 73 53 75 63 63 65 73 | writeW|asSucces|
|00003e00| 73 66 75 6c 20 3d 20 4e | 4f 3b 0a 09 09 20 20 62 |sful = N|O;... b|
|00003e10| 72 65 61 6b 3b 0a 09 09 | 7d 0a 09 20 20 20 20 20 |reak;...|}.. |
|00003e20| 20 0a 09 20 20 20 20 20 | 20 6d 65 6d 73 65 74 28 | .. | memset(|
|00003e30| 61 4c 69 6e 65 2c 20 30 | 2c 20 31 30 32 34 29 3b |aLine, 0|, 1024);|
|00003e40| 20 20 0a 09 20 20 20 20 | 7d 20 2f 2f 20 77 68 69 | .. |} // whi|
|00003e50| 6c 65 20 28 2e 2e 2e 29 | 0a 09 20 0a 09 20 20 2f |le (...)|.. .. /|
|00003e60| 2f 20 57 65 20 61 64 64 | 20 6f 75 72 20 6d 65 73 |/ We add| our mes|
|00003e70| 73 61 67 65 20 73 65 70 | 61 72 61 74 6f 72 0a 09 |sage sep|arator..|
|00003e80| 20 20 69 66 20 28 20 66 | 70 75 74 73 28 61 4c 69 | if ( f|puts(aLi|
|00003e90| 6e 65 2c 20 74 68 65 4f | 75 74 70 75 74 53 74 72 |ne, theO|utputStr|
|00003ea0| 65 61 6d 29 20 3c 20 30 | 20 29 0a 09 20 20 20 20 |eam) < 0| ).. |
|00003eb0| 7b 0a 09 20 20 20 20 20 | 20 77 72 69 74 65 57 61 |{.. | writeWa|
|00003ec0| 73 53 75 63 63 65 73 73 | 66 75 6c 20 3d 20 4e 4f |sSuccess|ful = NO|
|00003ed0| 3b 0a 09 20 20 20 20 20 | 20 62 72 65 61 6b 3b 0a |;.. | break;.|
|00003ee0| 09 20 20 20 20 7d 0a 0a | 09 20 20 2f 2f 20 57 65 |. }..|. // We|
|00003ef0| 20 75 70 64 61 74 65 20 | 6f 75 72 20 6d 65 73 73 | update |our mess|
|00003f00| 61 67 65 27 73 20 69 76 | 61 72 73 20 28 66 6f 6c |age's iv|ars (fol|
|00003f10| 64 65 72 20 61 6e 64 20 | 73 69 7a 65 20 64 6f 6e |der and |size don|
|00003f20| 27 74 20 63 68 61 6e 67 | 65 29 0a 09 20 20 5b 61 |'t chang|e).. [a|
|00003f30| 4d 65 73 73 61 67 65 20 | 73 65 74 46 69 6c 65 50 |Message |setFileP|
|00003f40| 6f 73 69 74 69 6f 6e 3a | 20 70 6f 73 69 74 69 6f |osition:| positio|
|00003f50| 6e 5d 3b 0a 09 20 20 5b | 61 4d 65 73 73 61 67 65 |n];.. [|aMessage|
|00003f60| 20 73 65 74 42 6f 64 79 | 46 69 6c 65 50 6f 73 69 | setBody|FilePosi|
|00003f70| 74 69 6f 6e 3a 20 28 70 | 6f 73 69 74 69 6f 6e 20 |tion: (p|osition |
|00003f80| 2b 20 68 65 61 64 65 72 | 73 5f 6c 65 6e 67 74 68 |+ header|s_length|
|00003f90| 29 5d 3b 0a 09 20 20 5b | 61 4d 65 73 73 61 67 65 |)];.. [|aMessage|
|00003fa0| 20 73 65 74 4d 65 73 73 | 61 67 65 4e 75 6d 62 65 | setMess|ageNumbe|
|00003fb0| 72 3a 20 6d 65 73 73 61 | 67 65 4e 75 6d 62 65 72 |r: messa|geNumber|
|00003fc0| 5d 3b 0a 09 20 20 0a 09 | 20 20 2f 2f 20 57 65 20 |];.. ..| // We |
|00003fd0| 69 6e 63 72 65 6d 65 6e | 74 20 6f 75 72 20 6d 65 |incremen|t our me|
|00003fe0| 73 73 61 67 65 4e 75 6d | 62 65 72 20 6c 6f 63 61 |ssageNum|ber loca|
|00003ff0| 6c 20 76 61 72 69 61 62 | 6c 65 0a 09 20 20 6d 65 |l variab|le.. me|
|00004000| 73 73 61 67 65 4e 75 6d | 62 65 72 2b 2b 3b 0a 09 |ssageNum|ber++;..|
|00004010| 7d 0a 20 20 20 20 20 20 | 0a 20 20 20 20 7d 20 2f |}. |. } /|
|00004020| 2f 20 66 6f 72 20 28 69 | 20 3d 20 30 3b 20 69 20 |/ for (i| = 0; i |
|00004030| 3c 20 63 6f 75 6e 74 3b | 20 69 2b 2b 29 0a 0a 20 |< count;| i++).. |
|00004040| 20 2f 2f 20 57 65 20 63 | 6c 6f 73 65 20 6f 75 72 | // We c|lose our|
|00004050| 20 6f 75 74 70 75 74 20 | 73 74 72 65 61 6d 0a 20 | output |stream. |
|00004060| 20 69 66 20 28 20 66 63 | 6c 6f 73 65 28 74 68 65 | if ( fc|lose(the|
|00004070| 4f 75 74 70 75 74 53 74 | 72 65 61 6d 29 20 21 3d |OutputSt|ream) !=|
|00004080| 20 30 20 29 0a 20 20 20 | 20 7b 0a 20 20 20 20 20 | 0 ). | {. |
|00004090| 20 77 72 69 74 65 57 61 | 73 53 75 63 63 65 73 73 | writeWa|sSuccess|
|000040a0| 66 75 6c 20 3d 20 4e 4f | 3b 0a 20 20 20 20 7d 0a |ful = NO|;. }.|
|000040b0| 20 0a 20 20 2f 2f 20 57 | 65 20 76 65 72 69 66 79 | . // W|e verify|
|000040c0| 20 69 66 20 74 68 65 20 | 6c 61 73 74 20 77 72 69 | if the |last wri|
|000040d0| 74 65 20 77 61 73 20 73 | 75 63 63 65 73 73 66 75 |te was s|uccessfu|
|000040e0| 6c 2c 20 69 66 20 79 65 | 73 2c 20 77 65 20 72 65 |l, if ye|s, we re|
|000040f0| 6d 6f 76 65 20 6f 75 72 | 20 6f 72 69 67 69 6e 61 |move our| origina|
|00004100| 6c 20 6d 61 69 6c 62 6f | 78 0a 20 20 2f 2f 20 61 |l mailbo|x. // a|
|00004110| 6e 64 20 77 65 20 72 65 | 70 6c 61 63 65 20 69 74 |nd we re|place it|
|00004120| 20 62 79 20 6f 75 72 20 | 74 65 6d 70 6f 72 61 72 | by our |temporar|
|00004130| 79 20 6d 61 69 6c 62 6f | 78 2e 0a 20 20 69 66 20 |y mailbo|x.. if |
|00004140| 28 20 77 72 69 74 65 57 | 61 73 53 75 63 63 65 73 |( writeW|asSucces|
|00004150| 73 66 75 6c 20 29 0a 20 | 20 20 20 7b 0a 20 20 20 |sful ). | {. |
|00004160| 20 20 20 2f 2f 20 57 65 | 20 63 6c 6f 73 65 20 74 | // We| close t|
|00004170| 68 65 20 63 75 72 72 65 | 6e 74 20 66 6f 6c 64 65 |he curre|nt folde|
|00004180| 72 0a 20 20 20 20 20 20 | 66 63 6c 6f 73 65 28 5b |r. |fclose([|
|00004190| 73 65 6c 66 20 73 74 72 | 65 61 6d 5d 29 3b 0a 20 |self str|eam]);. |
|000041a0| 20 20 20 20 20 66 6c 6f | 63 6b 28 5b 73 65 6c 66 | flo|ck([self|
|000041b0| 20 66 64 5d 2c 20 4c 4f | 43 4b 5f 55 4e 29 3b 0a | fd], LO|CK_UN);.|
|000041c0| 20 20 20 20 20 20 63 6c | 6f 73 65 28 5b 73 65 6c | cl|ose([sel|
|000041d0| 66 20 66 64 5d 29 3b 0a | 0a 20 20 20 20 20 20 2f |f fd]);.|. /|
|000041e0| 2f 20 4e 6f 77 20 74 68 | 61 74 20 45 76 65 72 79 |/ Now th|at Every|
|000041f0| 74 68 69 6e 67 20 69 73 | 20 61 6c 72 69 67 68 74 |thing is| alright|
|00004200| 2c 20 72 65 70 6c 61 63 | 65 20 3c 66 6f 6c 64 65 |, replac|e <folde|
|00004210| 72 20 6e 61 6d 65 3e 20 | 62 79 20 3c 66 6f 6c 64 |r name> |by <fold|
|00004220| 65 72 20 6e 61 6d 65 3e | 2e 74 6d 70 0a 20 20 20 |er name>|.tmp. |
|00004230| 20 20 20 5b 5b 4e 53 46 | 69 6c 65 4d 61 6e 61 67 | [[NSF|ileManag|
|00004240| 65 72 20 64 65 66 61 75 | 6c 74 4d 61 6e 61 67 65 |er defau|ltManage|
|00004250| 72 5d 20 72 65 6d 6f 76 | 65 46 69 6c 65 41 74 50 |r] remov|eFileAtP|
|00004260| 61 74 68 3a 20 70 61 74 | 68 54 6f 4d 61 69 6c 62 |ath: pat|hToMailb|
|00004270| 6f 78 0a 09 09 09 09 20 | 20 20 20 20 20 68 61 6e |ox..... | han|
|00004280| 64 6c 65 72 3a 20 6e 69 | 6c 5d 3b 0a 20 20 20 20 |dler: ni|l];. |
|00004290| 20 20 5b 5b 4e 53 46 69 | 6c 65 4d 61 6e 61 67 65 | [[NSFi|leManage|
|000042a0| 72 20 64 65 66 61 75 6c | 74 4d 61 6e 61 67 65 72 |r defaul|tManager|
|000042b0| 5d 20 6d 6f 76 65 50 61 | 74 68 3a 20 5b 4e 53 53 |] movePa|th: [NSS|
|000042c0| 74 72 69 6e 67 20 73 74 | 72 69 6e 67 57 69 74 68 |tring st|ringWith|
|000042d0| 46 6f 72 6d 61 74 3a 40 | 22 25 40 2e 74 6d 70 22 |Format:@|"%@.tmp"|
|000042e0| 2c 20 70 61 74 68 54 6f | 4d 61 69 6c 62 6f 78 5d |, pathTo|Mailbox]|
|000042f0| 0a 09 09 09 09 20 20 20 | 20 20 20 74 6f 50 61 74 |..... | toPat|
|00004300| 68 3a 20 70 61 74 68 54 | 6f 4d 61 69 6c 62 6f 78 |h: pathT|oMailbox|
|00004310| 0a 09 09 09 09 20 20 20 | 20 20 20 68 61 6e 64 6c |..... | handl|
|00004320| 65 72 3a 20 6e 69 6c 5d | 3b 0a 20 20 20 20 20 20 |er: nil]|;. |
|00004330| 0a 20 20 20 20 20 20 2f | 2f 20 57 65 20 73 79 6e |. /|/ We syn|
|00004340| 63 20 6f 75 72 20 63 61 | 63 68 65 0a 20 20 20 20 |c our ca|che. |
|00004350| 20 20 5b 5b 73 65 6c 66 | 20 6c 6f 63 61 6c 46 6f | [[self| localFo|
|00004360| 6c 64 65 72 43 61 63 68 | 65 4d 61 6e 61 67 65 72 |lderCach|eManager|
|00004370| 5d 20 73 79 6e 63 68 72 | 6f 6e 69 7a 65 5d 3b 0a |] synchr|onize];.|
|00004380| 0a 20 20 20 20 20 20 2f | 2f 20 4e 6f 77 20 77 65 |. /|/ Now we|
|00004390| 20 72 65 2d 6f 70 65 6e | 20 6f 75 72 20 66 6f 6c | re-open| our fol|
|000043a0| 64 65 72 20 61 6e 64 20 | 75 70 64 61 74 65 20 74 |der and |update t|
|000043b0| 68 65 20 27 61 6c 6c 4d | 65 73 73 61 67 65 73 27 |he 'allM|essages'|
|000043c0| 20 69 76 61 72 20 69 6e | 20 74 68 65 20 46 6f 6c | ivar in| the Fol|
|000043d0| 64 65 72 20 73 75 70 65 | 72 63 6c 61 73 73 0a 20 |der supe|rclass. |
|000043e0| 20 20 20 20 20 69 66 20 | 28 21 20 5b 73 65 6c 66 | if |(! [self|
|000043f0| 20 5f 6f 70 65 6e 41 6e | 64 4c 6f 63 6b 46 6f 6c | _openAn|dLockFol|
|00004400| 64 65 72 5d 20 29 0a 09 | 7b 0a 09 20 20 4e 53 44 |der] )..|{.. NSD|
|00004410| 65 62 75 67 4c 6f 67 28 | 40 22 41 20 66 61 74 61 |ebugLog(|@"A fata|
|00004420| 6c 20 65 72 72 6f 72 20 | 6f 63 63 75 72 65 64 20 |l error |occured |
|00004430| 69 6e 20 4c 6f 63 61 6c | 46 6f 6c 64 65 72 3a 20 |in Local|Folder: |
|00004440| 2d 65 78 70 75 6e 67 65 | 2e 22 29 3b 0a 09 7d 0a |-expunge|.");..}.|
|00004450| 0a 20 20 20 20 20 20 5b | 73 65 6c 66 20 73 65 74 |. [|self set|
|00004460| 4d 65 73 73 61 67 65 73 | 3a 20 5b 5b 73 65 6c 66 |Messages|: [[self|
|00004470| 20 6c 6f 63 61 6c 46 6f | 6c 64 65 72 43 61 63 68 | localFo|lderCach|
|00004480| 65 4d 61 6e 61 67 65 72 | 5d 20 6d 65 73 73 61 67 |eManager|] messag|
|00004490| 65 73 5d 5d 3b 0a 20 20 | 20 20 7d 0a 20 20 0a 20 |es]];. | }. . |
|000044a0| 20 2f 2f 20 54 68 65 20 | 6c 61 73 74 20 77 72 69 | // The |last wri|
|000044b0| 74 65 20 66 61 69 6c 65 | 64 2c 20 6c 65 74 27 73 |te faile|d, let's|
|000044c0| 20 72 65 6d 6f 76 65 20 | 6f 75 72 20 74 65 6d 70 | remove |our temp|
|000044d0| 6f 72 61 72 79 20 66 69 | 6c 65 20 61 6e 64 20 6b |orary fi|le and k|
|000044e0| 65 65 70 20 74 68 65 20 | 6f 72 69 67 69 6e 61 6c |eep the |original|
|000044f0| 20 6d 62 6f 78 20 77 68 | 69 63 68 2c 20 6d 69 67 | mbox wh|ich, mig|
|00004500| 68 74 0a 20 20 2f 2f 20 | 63 6f 6e 74 61 69 6e 73 |ht. // |contains|
|00004510| 20 6e 6f 6e 2d 75 70 64 | 61 74 65 64 20 73 74 61 | non-upd|ated sta|
|00004520| 74 75 73 20 66 6c 61 67 | 73 20 6f 72 20 6d 65 73 |tus flag|s or mes|
|00004530| 73 61 67 65 73 20 74 68 | 61 74 20 68 61 76 65 20 |sages th|at have |
|00004540| 62 65 65 6e 20 74 72 61 | 6e 73 66 65 72 72 65 64 |been tra|nsferred|
|00004550| 2f 64 65 6c 65 74 65 64 | 2e 0a 20 20 65 6c 73 65 |/deleted|.. else|
|00004560| 0a 20 20 20 20 7b 0a 20 | 20 20 20 20 20 4e 53 44 |. {. | NSD|
|00004570| 65 62 75 67 4c 6f 67 28 | 40 22 57 72 69 74 69 6e |ebugLog(|@"Writin|
|00004580| 67 20 74 6f 20 25 40 20 | 66 61 69 6c 65 64 2e 20 |g to %@ |failed. |
|00004590| 57 65 20 6b 65 65 70 20 | 74 68 65 20 6f 72 69 67 |We keep |the orig|
|000045a0| 69 6e 61 6c 20 6d 61 69 | 6c 62 6f 78 2e 22 2c 20 |inal mai|lbox.", |
|000045b0| 70 61 74 68 54 6f 4d 61 | 69 6c 62 6f 78 29 3b 0a |pathToMa|ilbox);.|
|000045c0| 20 20 20 20 20 20 4e 53 | 44 65 62 75 67 4c 6f 67 | NS|DebugLog|
|000045d0| 28 40 22 54 68 69 73 20 | 63 61 6e 20 62 65 20 64 |(@"This |can be d|
|000045e0| 75 65 20 74 6f 20 74 68 | 65 20 66 61 63 74 20 74 |ue to th|e fact t|
|000045f0| 68 61 74 20 79 6f 75 72 | 20 70 61 72 74 69 74 69 |hat your| partiti|
|00004600| 6f 6e 20 63 6f 6e 74 61 | 69 6e 69 6e 67 20 74 68 |on conta|ining th|
|00004610| 69 73 20 6d 61 69 6c 62 | 6f 78 20 69 73 20 66 75 |is mailb|ox is fu|
|00004620| 6c 6c 20 6f 72 20 74 68 | 61 74 20 79 6f 75 20 64 |ll or th|at you d|
|00004630| 6f 6e 27 74 20 68 61 76 | 65 20 77 72 69 74 65 20 |on't hav|e write |
|00004640| 70 65 72 6d 69 73 73 69 | 6f 6e 20 69 6e 20 74 68 |permissi|on in th|
|00004650| 65 20 64 69 72 65 63 74 | 6f 72 79 20 77 68 65 72 |e direct|ory wher|
|00004660| 65 20 74 68 69 73 20 6d | 61 69 6c 62 6f 78 20 69 |e this m|ailbox i|
|00004670| 73 2e 22 29 3b 0a 20 20 | 20 20 20 20 5b 5b 4e 53 |s.");. | [[NS|
|00004680| 46 69 6c 65 4d 61 6e 61 | 67 65 72 20 64 65 66 61 |FileMana|ger defa|
|00004690| 75 6c 74 4d 61 6e 61 67 | 65 72 5d 20 72 65 6d 6f |ultManag|er] remo|
|000046a0| 76 65 46 69 6c 65 41 74 | 50 61 74 68 3a 20 5b 4e |veFileAt|Path: [N|
|000046b0| 53 53 74 72 69 6e 67 20 | 73 74 72 69 6e 67 57 69 |SString |stringWi|
|000046c0| 74 68 46 6f 72 6d 61 74 | 3a 40 22 25 40 2e 74 6d |thFormat|:@"%@.tm|
|000046d0| 70 22 2c 20 70 61 74 68 | 54 6f 4d 61 69 6c 62 6f |p", path|ToMailbo|
|000046e0| 78 5d 0a 09 09 09 09 20 | 20 20 20 20 20 68 61 6e |x]..... | han|
|000046f0| 64 6c 65 72 3a 20 6e 69 | 6c 5d 3b 0a 20 20 20 20 |dler: ni|l];. |
|00004700| 7d 0a 20 20 0a 20 20 0a | 20 20 72 65 74 75 72 6e |}. . .| return|
|00004710| 20 41 55 54 4f 52 45 4c | 45 41 53 45 28 61 4d 75 | AUTOREL|EASE(aMu|
|00004720| 74 61 62 6c 65 41 72 72 | 61 79 29 3b 0a 7d 0a 0a |tableArr|ay);.}..|
|00004730| 0a 2f 2f 0a 2f 2f 20 61 | 63 63 65 73 73 20 2f 20 |.//.// a|ccess / |
|00004740| 6d 75 74 61 74 69 6f 6e | 20 6d 65 74 68 6f 64 73 |mutation| methods|
|00004750| 0a 2f 2f 0a 0a 2f 2f 0a | 2f 2f 20 54 68 69 73 20 |.//..//.|// This |
|00004760| 6d 65 74 68 6f 64 20 72 | 65 74 75 72 6e 73 20 74 |method r|eturns t|
|00004770| 68 65 20 66 69 6c 65 20 | 64 65 73 63 72 69 70 74 |he file |descript|
|00004780| 6f 72 20 75 73 65 64 20 | 62 79 20 74 68 69 73 20 |or used |by this |
|00004790| 6c 6f 63 61 6c 20 66 6f | 6c 64 65 72 2e 0a 2f 2f |local fo|lder..//|
|000047a0| 0a 2d 20 28 69 6e 74 29 | 20 66 64 0a 7b 0a 20 20 |.- (int)| fd.{. |
|000047b0| 72 65 74 75 72 6e 20 66 | 64 3b 0a 7d 0a 0a 0a 2f |return f|d;.}.../|
|000047c0| 2f 0a 2f 2f 20 54 68 69 | 73 20 6d 65 74 68 6f 64 |/.// Thi|s method|
|000047d0| 20 73 65 74 73 20 74 68 | 65 20 66 69 6c 65 20 64 | sets th|e file d|
|000047e0| 65 73 63 72 69 70 74 6f | 72 20 74 6f 20 62 65 20 |escripto|r to be |
|000047f0| 75 73 65 64 20 62 79 20 | 74 68 69 73 20 6c 6f 63 |used by |this loc|
|00004800| 61 6c 20 66 6f 6c 64 65 | 72 2e 0a 2f 2f 0a 2d 20 |al folde|r..//.- |
|00004810| 28 76 6f 69 64 29 20 73 | 65 74 46 44 3a 20 28 69 |(void) s|etFD: (i|
|00004820| 6e 74 29 20 74 68 65 46 | 44 0a 7b 0a 20 20 66 64 |nt) theF|D.{. fd|
|00004830| 20 3d 20 74 68 65 46 44 | 3b 0a 7d 0a 0a 2d 20 28 | = theFD|;.}..- (|
|00004840| 4e 53 53 74 72 69 6e 67 | 20 2a 29 20 70 61 74 68 |NSString| *) path|
|00004850| 0a 7b 0a 20 20 72 65 74 | 75 72 6e 20 70 61 74 68 |.{. ret|urn path|
|00004860| 3b 0a 7d 0a 0a 2d 20 28 | 76 6f 69 64 29 20 73 65 |;.}..- (|void) se|
|00004870| 74 50 61 74 68 3a 20 28 | 4e 53 53 74 72 69 6e 67 |tPath: (|NSString|
|00004880| 20 2a 29 20 74 68 65 50 | 61 74 68 0a 7b 0a 20 20 | *) theP|ath.{. |
|00004890| 52 45 54 41 49 4e 28 74 | 68 65 50 61 74 68 29 3b |RETAIN(t|hePath);|
|000048a0| 0a 20 20 52 45 4c 45 41 | 53 45 28 70 61 74 68 29 |. RELEA|SE(path)|
|000048b0| 3b 0a 20 20 70 61 74 68 | 20 3d 20 74 68 65 50 61 |;. path| = thePa|
|000048c0| 74 68 3b 0a 7d 0a 0a 2f | 2f 0a 2f 2f 20 54 68 69 |th;.}../|/.// Thi|
|000048d0| 73 20 6d 65 74 68 6f 64 | 20 72 65 74 75 72 6e 73 |s method| returns|
|000048e0| 20 74 68 65 20 66 69 6c | 65 20 73 74 72 65 61 6d | the fil|e stream|
|000048f0| 20 75 73 65 64 20 62 79 | 20 74 68 69 73 20 6c 6f | used by| this lo|
|00004900| 63 61 6c 20 66 6f 6c 64 | 65 72 2e 0a 2f 2f 0a 2d |cal fold|er..//.-|
|00004910| 20 28 46 49 4c 45 20 2a | 29 20 73 74 72 65 61 6d | (FILE *|) stream|
|00004920| 0a 7b 0a 20 20 72 65 74 | 75 72 6e 20 73 74 72 65 |.{. ret|urn stre|
|00004930| 61 6d 3b 0a 7d 0a 0a 0a | 2f 2f 0a 2f 2f 20 54 68 |am;.}...|//.// Th|
|00004940| 69 73 20 6d 65 74 68 6f | 64 20 73 65 74 73 20 74 |is metho|d sets t|
|00004950| 68 65 20 66 69 6c 65 20 | 73 74 72 65 61 6d 20 74 |he file |stream t|
|00004960| 6f 20 62 65 20 75 73 65 | 64 20 62 79 20 74 68 69 |o be use|d by thi|
|00004970| 73 20 6c 6f 63 61 6c 20 | 66 6f 6c 64 65 72 2e 0a |s local |folder..|
|00004980| 2f 2f 0a 2d 20 28 76 6f | 69 64 29 20 73 65 74 53 |//.- (vo|id) setS|
|00004990| 74 72 65 61 6d 3a 20 28 | 46 49 4c 45 20 2a 29 20 |tream: (|FILE *) |
|000049a0| 74 68 65 53 74 72 65 61 | 6d 0a 7b 0a 20 20 73 74 |theStrea|m.{. st|
|000049b0| 72 65 61 6d 20 3d 20 74 | 68 65 53 74 72 65 61 6d |ream = t|heStream|
|000049c0| 3b 0a 7d 0a 0a 0a 2d 20 | 28 4c 6f 63 61 6c 46 6f |;.}...- |(LocalFo|
|000049d0| 6c 64 65 72 43 61 63 68 | 65 4d 61 6e 61 67 65 72 |lderCach|eManager|
|000049e0| 20 2a 29 20 6c 6f 63 61 | 6c 46 6f 6c 64 65 72 43 | *) loca|lFolderC|
|000049f0| 61 63 68 65 4d 61 6e 61 | 67 65 72 0a 7b 0a 20 20 |acheMana|ger.{. |
|00004a00| 72 65 74 75 72 6e 20 6c | 6f 63 61 6c 46 6f 6c 64 |return l|ocalFold|
|00004a10| 65 72 43 61 63 68 65 4d | 61 6e 61 67 65 72 3b 0a |erCacheM|anager;.|
|00004a20| 7d 0a 0a 2d 20 28 76 6f | 69 64 29 20 73 65 74 4c |}..- (vo|id) setL|
|00004a30| 6f 63 61 6c 46 6f 6c 64 | 65 72 43 61 63 68 65 4d |ocalFold|erCacheM|
|00004a40| 61 6e 61 67 65 72 3a 20 | 28 4c 6f 63 61 6c 46 6f |anager: |(LocalFo|
|00004a50| 6c 64 65 72 43 61 63 68 | 65 4d 61 6e 61 67 65 72 |lderCach|eManager|
|00004a60| 20 2a 29 20 74 68 65 4c | 6f 63 61 6c 46 6f 6c 64 | *) theL|ocalFold|
|00004a70| 65 72 43 61 63 68 65 4d | 61 6e 61 67 65 72 0a 7b |erCacheM|anager.{|
|00004a80| 0a 20 20 69 66 20 28 20 | 74 68 65 4c 6f 63 61 6c |. if ( |theLocal|
|00004a90| 46 6f 6c 64 65 72 43 61 | 63 68 65 4d 61 6e 61 67 |FolderCa|cheManag|
|00004aa0| 65 72 20 29 0a 20 20 20 | 20 7b 0a 20 20 20 20 20 |er ). | {. |
|00004ab0| 20 52 45 54 41 49 4e 28 | 74 68 65 4c 6f 63 61 6c | RETAIN(|theLocal|
|00004ac0| 46 6f 6c 64 65 72 43 61 | 63 68 65 4d 61 6e 61 67 |FolderCa|cheManag|
|00004ad0| 65 72 29 3b 0a 20 20 20 | 20 20 20 52 45 4c 45 41 |er);. | RELEA|
|00004ae0| 53 45 28 6c 6f 63 61 6c | 46 6f 6c 64 65 72 43 61 |SE(local|FolderCa|
|00004af0| 63 68 65 4d 61 6e 61 67 | 65 72 29 3b 0a 20 20 20 |cheManag|er);. |
|00004b00| 20 20 20 6c 6f 63 61 6c | 46 6f 6c 64 65 72 43 61 | local|FolderCa|
|00004b10| 63 68 65 4d 61 6e 61 67 | 65 72 20 3d 20 74 68 65 |cheManag|er = the|
|00004b20| 4c 6f 63 61 6c 46 6f 6c | 64 65 72 43 61 63 68 65 |LocalFol|derCache|
|00004b30| 4d 61 6e 61 67 65 72 3b | 0a 20 20 20 20 7d 0a 20 |Manager;|. }. |
|00004b40| 20 65 6c 73 65 0a 20 20 | 20 20 7b 0a 20 20 20 20 | else. | {. |
|00004b50| 20 20 52 45 4c 45 41 53 | 45 28 6c 6f 63 61 6c 46 | RELEAS|E(localF|
|00004b60| 6f 6c 64 65 72 43 61 63 | 68 65 4d 61 6e 61 67 65 |olderCac|heManage|
|00004b70| 72 29 3b 0a 20 20 20 20 | 20 20 6c 6f 63 61 6c 46 |r);. | localF|
|00004b80| 6f 6c 64 65 72 43 61 63 | 68 65 4d 61 6e 61 67 65 |olderCac|heManage|
|00004b90| 72 20 3d 20 6e 69 6c 3b | 0a 20 20 20 20 7d 0a 7d |r = nil;|. }.}|
|00004ba0| 0a 0a 0a 2d 20 28 4e 53 | 44 69 63 74 69 6f 6e 61 |...- (NS|Dictiona|
|00004bb0| 72 79 20 2a 29 20 66 69 | 6c 65 41 74 74 72 69 62 |ry *) fi|leAttrib|
|00004bc0| 75 74 65 73 0a 7b 0a 20 | 20 72 65 74 75 72 6e 20 |utes.{. | return |
|00004bd0| 66 69 6c 65 41 74 74 72 | 69 62 75 74 65 73 3b 0a |fileAttr|ibutes;.|
|00004be0| 7d 0a 0a 2d 20 28 76 6f | 69 64 29 20 73 65 74 46 |}..- (vo|id) setF|
|00004bf0| 69 6c 65 41 74 74 72 69 | 62 75 74 65 73 3a 20 28 |ileAttri|butes: (|
|00004c00| 4e 53 44 69 63 74 69 6f | 6e 61 72 79 20 2a 29 20 |NSDictio|nary *) |
|00004c10| 74 68 65 41 74 74 72 69 | 62 75 74 65 73 0a 7b 0a |theAttri|butes.{.|
|00004c20| 20 20 52 45 54 41 49 4e | 28 74 68 65 41 74 74 72 | RETAIN|(theAttr|
|00004c30| 69 62 75 74 65 73 29 3b | 0a 20 20 52 45 4c 45 41 |ibutes);|. RELEA|
|00004c40| 53 45 28 66 69 6c 65 41 | 74 74 72 69 62 75 74 65 |SE(fileA|ttribute|
|00004c50| 73 29 3b 0a 20 20 66 69 | 6c 65 41 74 74 72 69 62 |s);. fi|leAttrib|
|00004c60| 75 74 65 73 20 3d 20 74 | 68 65 41 74 74 72 69 62 |utes = t|heAttrib|
|00004c70| 75 74 65 73 3b 0a 7d 0a | 0a 0a 2f 2f 0a 2f 2f 20 |utes;.}.|..//.// |
|00004c80| 54 68 69 73 20 6d 65 74 | 68 6f 64 20 69 73 20 75 |This met|hod is u|
|00004c90| 73 65 64 20 74 6f 20 61 | 70 70 65 6e 64 20 61 20 |sed to a|ppend a |
|00004ca0| 6d 65 73 73 61 67 65 20 | 74 6f 20 74 68 69 73 20 |message |to this |
|00004cb0| 66 6f 6c 64 65 72 2e 20 | 54 68 65 20 6d 65 73 73 |folder. |The mess|
|00004cc0| 61 67 65 0a 2f 2f 20 6d | 75 73 74 20 62 65 20 73 |age.// m|ust be s|
|00004cd0| 70 65 63 69 66 69 65 64 | 20 69 6e 20 72 61 77 20 |pecified| in raw |
|00004ce0| 73 6f 75 72 63 65 2e 20 | 54 68 65 20 6d 65 73 73 |source. |The mess|
|00004cf0| 61 67 65 20 69 73 20 61 | 70 70 65 6e 64 65 64 20 |age is a|ppended |
|00004d00| 74 6f 20 74 68 65 20 0a | 2f 2f 20 6c 6f 63 61 6c |to the .|// local|
|00004d10| 20 66 69 6c 65 20 61 6e | 64 20 69 73 20 69 6e 69 | file an|d is ini|
|00004d20| 74 69 61 6c 69 7a 65 64 | 20 61 66 74 65 72 2e 0a |tialized| after..|
|00004d30| 2f 2f 0a 2d 20 28 76 6f | 69 64 29 20 61 70 70 65 |//.- (vo|id) appe|
|00004d40| 6e 64 4d 65 73 73 61 67 | 65 46 72 6f 6d 52 61 77 |ndMessag|eFromRaw|
|00004d50| 53 6f 75 72 63 65 3a 20 | 28 4e 53 44 61 74 61 20 |Source: |(NSData |
|00004d60| 2a 29 20 74 68 65 44 61 | 74 61 0a 7b 0a 20 20 4e |*) theDa|ta.{. N|
|00004d70| 53 4d 75 74 61 62 6c 65 | 44 61 74 61 20 2a 61 4d |SMutable|Data *aM|
|00004d80| 75 74 61 62 6c 65 44 61 | 74 61 3b 0a 20 20 4e 53 |utableDa|ta;. NS|
|00004d90| 41 75 74 6f 72 65 6c 65 | 61 73 65 50 6f 6f 6c 20 |Autorele|asePool |
|00004da0| 2a 70 6f 6f 6c 3b 0a 20 | 20 4c 6f 63 61 6c 4d 65 |*pool;. | LocalMe|
|00004db0| 73 73 61 67 65 20 2a 61 | 4d 65 73 73 61 67 65 3b |ssage *a|Message;|
|00004dc0| 0a 20 20 4e 53 52 61 6e | 67 65 20 61 52 61 6e 67 |. NSRan|ge aRang|
|00004dd0| 65 3b 0a 20 20 0a 20 20 | 6c 6f 6e 67 20 6d 61 72 |e;. . |long mar|
|00004de0| 6b 2c 20 66 69 6c 65 50 | 6f 73 69 74 69 6f 6e 2c |k, fileP|osition,|
|00004df0| 20 62 6f 64 79 46 69 6c | 65 50 6f 73 69 74 69 6f | bodyFil|ePositio|
|00004e00| 6e 3b 0a 0a 20 20 70 6f | 6f 6c 20 3d 20 5b 5b 4e |n;.. po|ol = [[N|
|00004e10| 53 41 75 74 6f 72 65 6c | 65 61 73 65 50 6f 6f 6c |SAutorel|easePool|
|00004e20| 20 61 6c 6c 6f 63 5d 20 | 69 6e 69 74 5d 3b 0a 0a | alloc] |init];..|
|00004e30| 20 20 61 4d 75 74 61 62 | 6c 65 44 61 74 61 20 3d | aMutab|leData =|
|00004e40| 20 5b 5b 4e 53 4d 75 74 | 61 62 6c 65 44 61 74 61 | [[NSMut|ableData|
|00004e50| 20 61 6c 6c 6f 63 5d 20 | 69 6e 69 74 57 69 74 68 | alloc] |initWith|
|00004e60| 44 61 74 61 3a 20 74 68 | 65 44 61 74 61 5d 3b 0a |Data: th|eData];.|
|00004e70| 20 20 0a 20 20 2f 2f 20 | 57 65 20 6b 65 65 70 20 | . // |We keep |
|00004e80| 74 68 65 20 70 6f 73 69 | 74 69 6f 6e 20 77 68 65 |the posi|tion whe|
|00004e90| 72 65 20 77 65 20 77 65 | 72 65 20 69 6e 20 74 68 |re we we|re in th|
|00004ea0| 65 20 66 69 6c 65 0a 20 | 20 6d 61 72 6b 20 3d 20 |e file. | mark = |
|00004eb0| 66 74 65 6c 6c 28 20 5b | 73 65 6c 66 20 73 74 72 |ftell( [|self str|
|00004ec0| 65 61 6d 5d 20 29 3b 0a | 20 20 0a 20 20 2f 2f 4e |eam] );.| . //N|
|00004ed0| 53 44 65 62 75 67 4c 6f | 67 28 40 22 7c 25 73 7c |SDebugLo|g(@"|%s||
|00004ee0| 22 2c 20 5b 61 4d 75 74 | 61 62 6c 65 44 61 74 61 |", [aMut|ableData|
|00004ef0| 20 63 53 74 72 69 6e 67 | 5d 29 3b 0a 0a 20 20 2f | cString|]);.. /|
|00004f00| 2f 20 49 66 20 74 68 65 | 20 6d 65 73 73 61 67 65 |/ If the| message|
|00004f10| 20 64 6f 65 73 6e 27 74 | 20 63 6f 6e 74 61 69 6e | doesn't| contain|
|00004f20| 20 74 68 65 20 22 46 72 | 6f 6d 20 22 2c 20 77 65 | the "Fr|om ", we|
|00004f30| 20 61 64 64 20 69 74 0a | 20 20 69 66 20 28 21 20 | add it.| if (! |
|00004f40| 5b 61 4d 75 74 61 62 6c | 65 44 61 74 61 20 68 61 |[aMutabl|eData ha|
|00004f50| 73 43 50 72 65 66 69 78 | 3a 20 22 46 72 6f 6d 20 |sCPrefix|: "From |
|00004f60| 22 5d 20 29 0a 20 20 20 | 20 7b 0a 20 20 20 20 20 |"] ). | {. |
|00004f70| 20 2f 2f 20 57 65 20 6d | 75 73 74 20 61 64 64 20 | // We m|ust add |
|00004f80| 6f 75 72 20 6d 62 6f 78 | 20 64 65 6c 69 6d 69 74 |our mbox| delimit|
|00004f90| 65 72 0a 20 20 20 20 20 | 20 5b 61 4d 75 74 61 62 |er. | [aMutab|
|00004fa0| 6c 65 44 61 74 61 20 69 | 6e 73 65 72 74 43 53 74 |leData i|nsertCSt|
|00004fb0| 72 69 6e 67 3a 20 22 46 | 72 6f 6d 20 2d 5c 6e 22 |ring: "F|rom -\n"|
|00004fc0| 0a 09 09 20 20 20 20 61 | 74 49 6e 64 65 78 3a 20 |... a|tIndex: |
|00004fd0| 30 5d 3b 0a 20 20 20 20 | 7d 0a 0a 20 20 2f 2f 20 |0];. |}.. // |
|00004fe0| 57 65 20 4d 55 53 54 20 | 72 65 70 6c 61 63 65 20 |We MUST |replace |
|00004ff0| 65 76 65 72 79 20 22 5c | 6e 46 72 6f 6d 20 22 20 |every "\|nFrom " |
|00005000| 69 6e 20 74 68 65 20 6d | 65 73 73 61 67 65 20 62 |in the m|essage b|
|00005010| 79 20 22 5c 6e 3e 46 72 | 6f 6d 20 22 0a 20 20 61 |y "\n>Fr|om ". a|
|00005020| 52 61 6e 67 65 20 3d 20 | 5b 61 4d 75 74 61 62 6c |Range = |[aMutabl|
|00005030| 65 44 61 74 61 20 72 61 | 6e 67 65 4f 66 43 53 74 |eData ra|ngeOfCSt|
|00005040| 72 69 6e 67 3a 20 22 5c | 6e 46 72 6f 6d 20 22 5d |ring: "\|nFrom "]|
|00005050| 3b 0a 20 20 0a 20 20 77 | 68 69 6c 65 20 28 61 52 |;. . w|hile (aR|
|00005060| 61 6e 67 65 2e 6c 6f 63 | 61 74 69 6f 6e 20 21 3d |ange.loc|ation !=|
|00005070| 20 4e 53 4e 6f 74 46 6f | 75 6e 64 29 0a 20 20 20 | NSNotFo|und). |
|00005080| 20 7b 0a 20 20 20 20 20 | 20 5b 61 4d 75 74 61 62 | {. | [aMutab|
|00005090| 6c 65 44 61 74 61 20 72 | 65 70 6c 61 63 65 42 79 |leData r|eplaceBy|
|000050a0| 74 65 73 49 6e 52 61 6e | 67 65 3a 20 61 52 61 6e |tesInRan|ge: aRan|
|000050b0| 67 65 0a 09 09 20 20 20 | 20 77 69 74 68 42 79 74 |ge... | withByt|
|000050c0| 65 73 3a 20 22 5c 6e 3e | 46 72 6f 6d 20 22 5d 3b |es: "\n>|From "];|
|000050d0| 0a 20 20 20 20 20 20 0a | 20 20 20 20 20 20 61 52 |. .| aR|
|000050e0| 61 6e 67 65 20 3d 20 5b | 61 4d 75 74 61 62 6c 65 |ange = [|aMutable|
|000050f0| 44 61 74 61 20 72 61 6e | 67 65 4f 66 43 53 74 72 |Data ran|geOfCStr|
|00005100| 69 6e 67 3a 20 22 5c 6e | 46 72 6f 6d 20 22 0a 09 |ing: "\n|From "..|
|00005110| 09 09 20 20 20 20 20 6f | 70 74 69 6f 6e 73 3a 20 |.. o|ptions: |
|00005120| 30 0a 09 09 09 20 20 20 | 20 20 72 61 6e 67 65 3a |0.... | range:|
|00005130| 20 4e 53 4d 61 6b 65 52 | 61 6e 67 65 28 61 52 61 | NSMakeR|ange(aRa|
|00005140| 6e 67 65 2e 6c 6f 63 61 | 74 69 6f 6e 20 2b 20 61 |nge.loca|tion + a|
|00005150| 52 61 6e 67 65 2e 6c 65 | 6e 67 74 68 2c 0a 09 09 |Range.le|ngth,...|
|00005160| 09 09 09 09 5b 61 4d 75 | 74 61 62 6c 65 44 61 74 |....[aMu|tableDat|
|00005170| 61 20 6c 65 6e 67 74 68 | 5d 20 2d 20 61 52 61 6e |a length|] - aRan|
|00005180| 67 65 2e 6c 6f 63 61 74 | 69 6f 6e 20 2d 20 61 52 |ge.locat|ion - aR|
|00005190| 61 6e 67 65 2e 6c 65 6e | 67 74 68 29 20 5d 3b 0a |ange.len|gth) ];.|
|000051a0| 20 20 20 20 7d 0a 20 20 | 0a 20 20 2f 2f 20 57 65 | }. |. // We|
|000051b0| 20 61 64 64 20 6f 75 72 | 20 6d 65 73 73 61 67 65 | add our| message|
|000051c0| 20 73 65 70 61 72 61 74 | 6f 72 20 74 6f 20 74 68 | separat|or to th|
|000051d0| 65 20 65 6e 64 20 6f 66 | 20 74 68 65 20 72 61 77 |e end of| the raw|
|000051e0| 20 73 6f 75 72 63 65 20 | 6f 66 20 74 68 69 73 20 | source |of this |
|000051f0| 6d 65 73 73 61 67 65 0a | 20 20 2f 2f 20 49 74 27 |message.| // It'|
|00005200| 73 20 61 20 73 69 6d 70 | 6c 65 20 5c 6e 20 69 6e |s a simp|le \n in|
|00005210| 20 74 68 65 20 6d 62 6f | 78 20 66 6f 72 6d 61 74 | the mbo|x format|
|00005220| 2e 0a 20 20 5b 61 4d 75 | 74 61 62 6c 65 44 61 74 |.. [aMu|tableDat|
|00005230| 61 20 61 70 70 65 6e 64 | 43 53 74 72 69 6e 67 3a |a append|CString:|
|00005240| 20 22 5c 6e 22 5d 3b 0a | 0a 20 20 2f 2f 20 57 65 | "\n"];.|. // We|
|00005250| 20 67 6f 20 61 74 20 74 | 68 65 20 65 6e 64 20 6f | go at t|he end o|
|00005260| 66 20 74 68 65 20 66 69 | 6c 65 2e 2e 2e 0a 20 20 |f the fi|le.... |
|00005270| 69 66 20 28 20 66 73 65 | 65 6b 28 5b 73 65 6c 66 |if ( fse|ek([self|
|00005280| 20 73 74 72 65 61 6d 5d | 2c 20 30 4c 2c 20 53 45 | stream]|, 0L, SE|
|00005290| 45 4b 5f 45 4e 44 29 20 | 3c 20 30 20 29 0a 20 20 |EK_END) |< 0 ). |
|000052a0| 20 20 7b 0a 20 20 20 20 | 20 20 4e 53 45 78 63 65 | {. | NSExce|
|000052b0| 70 74 69 6f 6e 20 2a 61 | 6e 45 78 63 65 70 74 69 |ption *a|nExcepti|
|000052c0| 6f 6e 3b 0a 20 20 20 20 | 20 20 0a 20 20 20 20 20 |on;. | . |
|000052d0| 20 4e 53 44 65 62 75 67 | 4c 6f 67 28 40 22 45 72 | NSDebug|Log(@"Er|
|000052e0| 72 6f 72 20 69 6e 20 73 | 65 65 6b 69 6e 67 20 74 |ror in s|eeking t|
|000052f0| 6f 20 74 68 65 20 65 6e | 64 20 6f 66 20 74 68 65 |o the en|d of the|
|00005300| 20 6c 6f 63 61 6c 20 66 | 6f 6c 64 65 72 2e 22 29 | local f|older.")|
|00005310| 3b 0a 20 20 20 20 20 20 | 0a 20 20 20 20 20 20 52 |;. |. R|
|00005320| 45 4c 45 41 53 45 28 61 | 4d 75 74 61 62 6c 65 44 |ELEASE(a|MutableD|
|00005330| 61 74 61 29 3b 0a 20 20 | 20 20 20 20 0a 20 20 20 |ata);. | . |
|00005340| 20 20 20 61 6e 45 78 63 | 65 70 74 69 6f 6e 20 3d | anExc|eption =|
|00005350| 20 5b 4e 53 45 78 63 65 | 70 74 69 6f 6e 20 65 78 | [NSExce|ption ex|
|00005360| 63 65 70 74 69 6f 6e 57 | 69 74 68 4e 61 6d 65 3a |ceptionW|ithName:|
|00005370| 20 40 22 50 61 6e 74 6f | 6d 69 6d 65 46 6f 6c 64 | @"Panto|mimeFold|
|00005380| 65 72 41 70 70 65 6e 64 | 4d 65 73 73 61 67 65 45 |erAppend|MessageE|
|00005390| 78 63 65 70 74 69 6f 6e | 22 0a 09 09 09 09 20 72 |xception|"..... r|
|000053a0| 65 61 73 6f 6e 3a 20 40 | 22 45 72 72 6f 72 20 69 |eason: @|"Error i|
|000053b0| 6e 20 73 65 65 6b 69 6e | 67 20 74 6f 20 74 68 65 |n seekin|g to the|
|000053c0| 20 65 6e 64 20 6f 66 20 | 74 68 65 20 6c 6f 63 61 | end of |the loca|
|000053d0| 6c 20 66 6f 6c 64 65 72 | 2e 22 0a 09 09 09 09 20 |l folder|."..... |
|000053e0| 75 73 65 72 49 6e 66 6f | 3a 20 6e 69 6c 5d 3b 0a |userInfo|: nil];.|
|000053f0| 20 20 20 20 20 20 5b 61 | 6e 45 78 63 65 70 74 69 | [a|nExcepti|
|00005400| 6f 6e 20 72 61 69 73 65 | 5d 3b 0a 20 20 20 20 20 |on raise|];. |
|00005410| 20 72 65 74 75 72 6e 3b | 0a 20 20 20 20 7d 0a 20 | return;|. }. |
|00005420| 20 0a 20 20 2f 2f 20 57 | 65 20 67 65 74 20 74 68 | . // W|e get th|
|00005430| 65 20 70 6f 73 69 74 69 | 6f 6e 20 6f 66 20 6f 75 |e positi|on of ou|
|00005440| 72 20 6d 65 73 73 61 67 | 65 20 69 6e 20 74 68 65 |r messag|e in the|
|00005450| 20 66 69 6c 65 0a 20 20 | 66 69 6c 65 50 6f 73 69 | file. |filePosi|
|00005460| 74 69 6f 6e 20 3d 20 66 | 74 65 6c 6c 28 20 5b 73 |tion = f|tell( [s|
|00005470| 65 6c 66 20 73 74 72 65 | 61 6d 5d 20 29 3b 0a 0a |elf stre|am] );..|
|00005480| 20 20 2f 2f 20 57 65 20 | 67 65 74 20 74 68 65 20 | // We |get the |
|00005490| 62 6f 64 79 20 70 6f 73 | 69 74 69 6f 6e 20 6f 66 |body pos|ition of|
|000054a0| 20 74 68 65 20 62 6f 64 | 79 0a 20 20 61 52 61 6e | the bod|y. aRan|
|000054b0| 67 65 20 3d 20 5b 61 4d | 75 74 61 62 6c 65 44 61 |ge = [aM|utableDa|
|000054c0| 74 61 20 72 61 6e 67 65 | 4f 66 43 53 74 72 69 6e |ta range|OfCStrin|
|000054d0| 67 3a 20 22 5c 6e 5c 6e | 22 5d 3b 0a 20 20 62 6f |g: "\n\n|"];. bo|
|000054e0| 64 79 46 69 6c 65 50 6f | 73 69 74 69 6f 6e 20 3d |dyFilePo|sition =|
|000054f0| 20 66 69 6c 65 50 6f 73 | 69 74 69 6f 6e 20 2b 20 | filePos|ition + |
|00005500| 61 52 61 6e 67 65 2e 6c | 6f 63 61 74 69 6f 6e 20 |aRange.l|ocation |
|00005510| 2b 20 32 3b 0a 20 20 0a | 20 20 2f 2f 20 57 65 20 |+ 2;. .| // We |
|00005520| 77 72 69 74 65 20 74 68 | 65 20 73 74 72 69 6e 67 |write th|e string|
|00005530| 20 74 6f 20 6f 75 72 20 | 6c 6f 63 61 6c 20 66 6f | to our |local fo|
|00005540| 6c 64 65 72 0a 20 20 69 | 66 20 28 20 66 77 72 69 |lder. i|f ( fwri|
|00005550| 74 65 28 5b 61 4d 75 74 | 61 62 6c 65 44 61 74 61 |te([aMut|ableData|
|00005560| 20 62 79 74 65 73 5d 2c | 20 31 2c 20 5b 61 4d 75 | bytes],| 1, [aMu|
|00005570| 74 61 62 6c 65 44 61 74 | 61 20 6c 65 6e 67 74 68 |tableDat|a length|
|00005580| 5d 2c 20 5b 73 65 6c 66 | 20 73 74 72 65 61 6d 5d |], [self| stream]|
|00005590| 29 20 3c 3d 20 30 20 29 | 0a 20 20 20 20 7b 0a 20 |) <= 0 )|. {. |
|000055a0| 20 20 20 20 20 4e 53 45 | 78 63 65 70 74 69 6f 6e | NSE|xception|
|000055b0| 20 2a 61 6e 45 78 63 65 | 70 74 69 6f 6e 3b 0a 20 | *anExce|ption;. |
|000055c0| 20 20 20 20 20 0a 20 20 | 20 20 20 20 4e 53 44 65 | . | NSDe|
|000055d0| 62 75 67 4c 6f 67 28 40 | 22 45 72 72 6f 72 20 69 |bugLog(@|"Error i|
|000055e0| 6e 20 61 70 70 65 6e 64 | 69 6e 67 20 74 68 65 20 |n append|ing the |
|000055f0| 72 61 77 20 73 6f 75 72 | 63 65 20 6f 66 20 61 20 |raw sour|ce of a |
|00005600| 6d 65 73 73 61 67 65 20 | 74 6f 20 74 68 65 20 6c |message |to the l|
|00005610| 6f 63 61 6c 20 66 6f 6c | 64 65 72 2e 22 29 3b 0a |ocal fol|der.");.|
|00005620| 0a 20 20 20 20 20 20 52 | 45 4c 45 41 53 45 28 61 |. R|ELEASE(a|
|00005630| 4d 75 74 61 62 6c 65 44 | 61 74 61 29 3b 0a 20 20 |MutableD|ata);. |
|00005640| 20 20 20 20 0a 20 20 20 | 20 20 20 61 6e 45 78 63 | . | anExc|
|00005650| 65 70 74 69 6f 6e 20 3d | 20 5b 4e 53 45 78 63 65 |eption =| [NSExce|
|00005660| 70 74 69 6f 6e 20 65 78 | 63 65 70 74 69 6f 6e 57 |ption ex|ceptionW|
|00005670| 69 74 68 4e 61 6d 65 3a | 20 40 22 50 61 6e 74 6f |ithName:| @"Panto|
|00005680| 6d 69 6d 65 46 6f 6c 64 | 65 72 41 70 70 65 6e 64 |mimeFold|erAppend|
|00005690| 4d 65 73 73 61 67 65 45 | 78 63 65 70 74 69 6f 6e |MessageE|xception|
|000056a0| 22 0a 09 09 09 09 20 72 | 65 61 73 6f 6e 3a 20 40 |"..... r|eason: @|
|000056b0| 22 45 72 72 6f 72 20 69 | 6e 20 61 70 70 65 6e 64 |"Error i|n append|
|000056c0| 69 6e 67 20 74 68 65 20 | 72 61 77 20 73 6f 75 72 |ing the |raw sour|
|000056d0| 63 65 20 6f 66 20 61 20 | 6d 65 73 73 61 67 65 20 |ce of a |message |
|000056e0| 74 6f 20 74 68 65 20 6c | 6f 63 61 6c 20 66 6f 6c |to the l|ocal fol|
|000056f0| 64 65 72 2e 22 0a 09 09 | 09 09 20 75 73 65 72 49 |der."...|.. userI|
|00005700| 6e 66 6f 3a 20 6e 69 6c | 5d 3b 0a 20 20 20 20 20 |nfo: nil|];. |
|00005710| 20 5b 61 6e 45 78 63 65 | 70 74 69 6f 6e 20 72 61 | [anExce|ption ra|
|00005720| 69 73 65 5d 3b 0a 20 20 | 20 20 20 20 72 65 74 75 |ise];. | retu|
|00005730| 72 6e 3b 0a 20 20 20 20 | 7d 0a 20 20 0a 20 20 2f |rn;. |}. . /|
|00005740| 2f 20 57 65 20 6e 6f 77 | 20 63 72 65 61 74 65 20 |/ We now| create |
|00005750| 74 68 65 20 6d 65 73 73 | 61 67 65 20 66 72 6f 6d |the mess|age from|
|00005760| 20 74 68 65 20 72 61 77 | 20 73 6f 75 72 63 65 20 | the raw| source |
|00005770| 62 79 20 75 73 69 6e 67 | 20 6f 6e 6c 79 20 74 68 |by using| only th|
|00005780| 65 20 68 65 61 64 65 72 | 73 2e 0a 20 20 61 4d 65 |e header|s.. aMe|
|00005790| 73 73 61 67 65 20 3d 20 | 5b 5b 4c 6f 63 61 6c 4d |ssage = |[[LocalM|
|000057a0| 65 73 73 61 67 65 20 61 | 6c 6c 6f 63 5d 20 69 6e |essage a|lloc] in|
|000057b0| 69 74 57 69 74 68 48 65 | 61 64 65 72 73 46 72 6f |itWithHe|adersFro|
|000057c0| 6d 44 61 74 61 3a 0a 09 | 09 09 09 20 20 20 20 20 |mData:..|... |
|000057d0| 5b 4d 69 6d 65 55 74 69 | 6c 69 74 79 20 75 6e 66 |[MimeUti|lity unf|
|000057e0| 6f 6c 64 4c 69 6e 65 73 | 46 72 6f 6d 44 61 74 61 |oldLines|FromData|
|000057f0| 3a 20 5b 61 4d 75 74 61 | 62 6c 65 44 61 74 61 20 |: [aMuta|bleData |
|00005800| 73 75 62 64 61 74 61 54 | 6f 49 6e 64 65 78 3a 20 |subdataT|oIndex: |
|00005810| 61 52 61 6e 67 65 2e 6c | 6f 63 61 74 69 6f 6e 20 |aRange.l|ocation |
|00005820| 2b 20 31 5d 5d 5d 3b 0a | 20 20 20 20 0a 20 20 5b |+ 1]]];.| . [|
|00005830| 61 4d 65 73 73 61 67 65 | 20 73 65 74 46 69 6c 65 |aMessage| setFile|
|00005840| 50 6f 73 69 74 69 6f 6e | 3a 20 66 69 6c 65 50 6f |Position|: filePo|
|00005850| 73 69 74 69 6f 6e 5d 3b | 0a 20 20 5b 61 4d 65 73 |sition];|. [aMes|
|00005860| 73 61 67 65 20 73 65 74 | 42 6f 64 79 46 69 6c 65 |sage set|BodyFile|
|00005870| 50 6f 73 69 74 69 6f 6e | 3a 20 62 6f 64 79 46 69 |Position|: bodyFi|
|00005880| 6c 65 50 6f 73 69 74 69 | 6f 6e 5d 3b 0a 20 20 5b |lePositi|on];. [|
|00005890| 61 4d 65 73 73 61 67 65 | 20 73 65 74 53 69 7a 65 |aMessage| setSize|
|000058a0| 3a 20 28 20 66 74 65 6c | 6c 28 20 5b 73 65 6c 66 |: ( ftel|l( [self|
|000058b0| 20 73 74 72 65 61 6d 5d | 20 29 20 2d 20 66 69 6c | stream]| ) - fil|
|000058c0| 65 50 6f 73 69 74 69 6f | 6e 29 20 5d 3b 0a 20 20 |ePositio|n) ];. |
|000058d0| 5b 61 4d 65 73 73 61 67 | 65 20 73 65 74 4d 65 73 |[aMessag|e setMes|
|000058e0| 73 61 67 65 4e 75 6d 62 | 65 72 3a 20 28 28 5b 73 |sageNumb|er: (([s|
|000058f0| 65 6c 66 20 63 6f 75 6e | 74 5d 20 2b 20 31 29 20 |elf coun|t] + 1) |
|00005900| 2b 20 5b 73 65 6c 66 20 | 6e 75 6d 62 65 72 4f 66 |+ [self |numberOf|
|00005910| 54 72 61 6e 73 66 65 72 | 72 65 64 4d 65 73 73 61 |Transfer|redMessa|
|00005920| 67 65 73 5d 29 5d 3b 0a | 20 20 5b 61 4d 65 73 73 |ges])];.| [aMess|
|00005930| 61 67 65 20 73 65 74 46 | 6f 6c 64 65 72 3a 20 73 |age setF|older: s|
|00005940| 65 6c 66 5d 3b 0a 20 20 | 0a 20 20 2f 2f 20 57 65 |elf];. |. // We|
|00005950| 20 61 70 70 65 6e 64 20 | 69 74 20 74 6f 20 6f 75 | append |it to ou|
|00005960| 72 20 66 6f 6c 64 65 72 | 0a 20 20 5b 73 65 6c 66 |r folder|. [self|
|00005970| 20 61 70 70 65 6e 64 4d | 65 73 73 61 67 65 3a 20 | appendM|essage: |
|00005980| 61 4d 65 73 73 61 67 65 | 5d 3b 0a 20 20 0a 20 20 |aMessage|];. . |
|00005990| 2f 2f 20 57 65 20 61 6c | 73 6f 20 61 70 70 65 6e |// We al|so appen|
|000059a0| 64 20 69 74 20 74 6f 20 | 6f 75 72 20 63 61 63 68 |d it to |our cach|
|000059b0| 65 0a 20 20 69 66 20 28 | 20 6c 6f 63 61 6c 46 6f |e. if (| localFo|
|000059c0| 6c 64 65 72 43 61 63 68 | 65 4d 61 6e 61 67 65 72 |lderCach|eManager|
|000059d0| 20 29 0a 20 20 20 20 7b | 0a 20 20 20 20 20 20 5b | ). {|. [|
|000059e0| 6c 6f 63 61 6c 46 6f 6c | 64 65 72 43 61 63 68 65 |localFol|derCache|
|000059f0| 4d 61 6e 61 67 65 72 20 | 61 64 64 4d 65 73 73 61 |Manager |addMessa|
|00005a00| 67 65 3a 20 61 4d 65 73 | 73 61 67 65 5d 3b 0a 20 |ge: aMes|sage];. |
|00005a10| 20 20 20 7d 0a 20 20 0a | 20 20 52 45 4c 45 41 53 | }. .| RELEAS|
|00005a20| 45 28 61 4d 65 73 73 61 | 67 65 29 3b 0a 0a 20 20 |E(aMessa|ge);.. |
|00005a30| 2f 2f 20 57 65 20 66 69 | 6e 61 6c 6c 79 20 72 65 |// We fi|nally re|
|00005a40| 73 65 74 20 6f 75 72 20 | 66 70 20 77 68 65 72 65 |set our |fp where|
|00005a50| 20 74 68 65 20 6d 61 72 | 6b 20 77 61 73 20 73 65 | the mar|k was se|
|00005a60| 74 0a 20 20 66 73 65 65 | 6b 28 5b 73 65 6c 66 20 |t. fsee|k([self |
|00005a70| 73 74 72 65 61 6d 5d 2c | 20 6d 61 72 6b 2c 20 53 |stream],| mark, S|
|00005a80| 45 45 4b 5f 53 45 54 29 | 3b 0a 0a 20 20 52 45 4c |EEK_SET)|;.. REL|
|00005a90| 45 41 53 45 28 61 4d 75 | 74 61 62 6c 65 44 61 74 |EASE(aMu|tableDat|
|00005aa0| 61 29 3b 0a 20 20 52 45 | 4c 45 41 53 45 28 70 6f |a);. RE|LEASE(po|
|00005ab0| 6f 6c 29 3b 0a 7d 0a 0a | 40 65 6e 64 0a 0a 0a 2f |ol);.}..|@end.../|
|00005ac0| 2f 0a 2f 2f 20 50 72 69 | 76 61 74 65 20 6d 65 74 |/.// Pri|vate met|
|00005ad0| 68 6f 64 73 0a 2f 2f 0a | 40 69 6d 70 6c 65 6d 65 |hods.//.|@impleme|
|00005ae0| 6e 74 61 74 69 6f 6e 20 | 4c 6f 63 61 6c 46 6f 6c |ntation |LocalFol|
|00005af0| 64 65 72 20 28 50 72 69 | 76 61 74 65 29 0a 0a 2d |der (Pri|vate)..-|
|00005b00| 20 28 42 4f 4f 4c 29 20 | 5f 6f 70 65 6e 41 6e 64 | (BOOL) |_openAnd|
|00005b10| 4c 6f 63 6b 46 6f 6c 64 | 65 72 0a 7b 0a 20 20 66 |LockFold|er.{. f|
|00005b20| 64 20 3d 20 6f 70 65 6e | 28 5b 5b 73 65 6c 66 20 |d = open|([[self |
|00005b30| 70 61 74 68 5d 20 63 53 | 74 72 69 6e 67 5d 2c 20 |path] cS|tring], |
|00005b40| 4f 5f 52 44 57 52 29 3b | 0a 20 20 0a 20 20 69 66 |O_RDWR);|. . if|
|00005b50| 20 28 66 64 20 3c 20 30 | 29 0a 20 20 20 20 7b 0a | (fd < 0|). {.|
|00005b60| 20 20 20 20 20 20 4e 53 | 44 65 62 75 67 4c 6f 67 | NS|DebugLog|
|00005b70| 28 40 22 4c 6f 63 61 6c | 46 6f 6c 64 65 72 3a 20 |(@"Local|Folder: |
|00005b80| 55 6e 61 62 6c 65 20 74 | 6f 20 67 65 74 20 66 6f |Unable t|o get fo|
|00005b90| 6c 64 65 72 20 64 65 73 | 63 72 69 70 74 6f 72 2e |lder des|criptor.|
|00005ba0| 2e 2e 22 29 3b 0a 20 20 | 20 20 20 20 72 65 74 75 |..");. | retu|
|00005bb0| 72 6e 20 4e 4f 3b 0a 20 | 20 20 20 7d 0a 20 20 0a |rn NO;. | }. .|
|00005bc0| 20 20 69 66 20 28 66 6c | 6f 63 6b 28 66 64 2c 20 | if (fl|ock(fd, |
|00005bd0| 4c 4f 43 4b 5f 45 58 7c | 4c 4f 43 4b 5f 4e 42 29 |LOCK_EX||LOCK_NB)|
|00005be0| 20 3c 20 30 29 20 0a 20 | 20 20 20 7b 0a 20 20 20 | < 0) . | {. |
|00005bf0| 20 20 20 4e 53 44 65 62 | 75 67 4c 6f 67 28 40 22 | NSDeb|ugLog(@"|
|00005c00| 4c 6f 63 61 6c 46 6f 6c | 64 65 72 3a 20 55 6e 61 |LocalFol|der: Una|
|00005c10| 62 6c 65 20 74 6f 20 6f | 62 74 61 69 6e 20 74 68 |ble to o|btain th|
|00005c20| 65 20 6c 6f 63 6b 20 6f | 6e 20 74 68 65 20 66 6f |e lock o|n the fo|
|00005c30| 6c 64 65 72 20 64 65 73 | 63 72 69 70 74 6f 72 2e |lder des|criptor.|
|00005c40| 2e 2e 22 29 3b 0a 20 20 | 20 20 20 20 72 65 74 75 |..");. | retu|
|00005c50| 72 6e 20 4e 4f 3b 0a 20 | 20 20 20 7d 0a 20 20 65 |rn NO;. | }. e|
|00005c60| 6c 73 65 20 0a 20 20 20 | 20 7b 0a 20 20 20 20 20 |lse . | {. |
|00005c70| 20 66 6c 6f 63 6b 28 66 | 64 2c 20 4c 4f 43 4b 5f | flock(f|d, LOCK_|
|00005c80| 55 4e 29 3b 0a 20 20 20 | 20 7d 0a 0a 20 20 73 74 |UN);. | }.. st|
|00005c90| 72 65 61 6d 20 3d 20 66 | 64 6f 70 65 6e 28 66 64 |ream = f|dopen(fd|
|00005ca0| 2c 20 22 72 2b 22 29 3b | 0a 0a 20 20 69 66 20 28 |, "r+");|.. if (|
|00005cb0| 73 74 72 65 61 6d 20 3d | 3d 20 4e 55 4c 4c 29 0a |stream =|= NULL).|
|00005cc0| 20 20 20 20 7b 0a 20 20 | 20 20 20 20 4e 53 44 65 | {. | NSDe|
|00005cd0| 62 75 67 4c 6f 67 28 40 | 22 4c 6f 63 61 6c 46 6f |bugLog(@|"LocalFo|
|00005ce0| 6c 64 65 72 3a 20 55 6e | 61 62 6c 65 20 74 6f 20 |lder: Un|able to |
|00005cf0| 6f 70 65 6e 20 74 68 65 | 20 73 70 65 63 69 66 69 |open the| specifi|
|00005d00| 65 64 20 6d 61 69 6c 62 | 6f 78 2e 2e 2e 22 29 3b |ed mailb|ox...");|
|00005d10| 0a 20 20 20 20 20 20 72 | 65 74 75 72 6e 20 4e 4f |. r|eturn NO|
|00005d20| 3b 0a 20 20 20 20 7d 0a | 0a 20 20 66 6c 6f 63 6b |;. }.|. flock|
|00005d30| 28 66 64 2c 20 4c 4f 43 | 4b 5f 45 58 7c 4c 4f 43 |(fd, LOC|K_EX|LOC|
|00005d40| 4b 5f 4e 42 29 3b 0a 0a | 20 20 72 65 74 75 72 6e |K_NB);..| return|
|00005d50| 20 59 45 53 3b 0a 7d 0a | 0a 40 65 6e 64 0a 00 00 | YES;.}.|.@end...|
|00005d60| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005d70| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005d80| 00 00 01 00 00 00 01 00 | 00 00 00 00 00 00 00 1e |........|........|
|00005d90| 54 68 69 73 20 72 65 73 | 6f 75 72 63 65 20 66 6f |This res|ource fo|
|00005da0| 72 6b 20 69 6e 74 65 6e | 74 69 6f 6e 61 6c 6c 79 |rk inten|tionally|
|00005db0| 20 6c 65 66 74 20 62 6c | 61 6e 6b 20 20 20 00 00 | left bl|ank ..|
|00005dc0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005dd0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005de0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005df0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005e00| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005e10| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005e20| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005e30| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005e40| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005e50| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005e60| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005e70| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005e80| 00 00 01 00 00 00 01 00 | 00 00 00 00 00 00 00 1e |........|........|
|00005e90| 00 00 00 00 00 00 00 00 | 00 1c 00 1e ff ff 00 00 |........|........|
|00005ea0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005eb0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005ec0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005ed0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005ee0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00005ef0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+